Untitled

 avatar
unknown
plain_text
a year ago
1.3 kB
5
Indexable
"""W.A.P to perform the following operation on a list of names
•	Create a List of 5 names (Anil, Anmol, Aditya, Alka, Avi)
•	Insert the name Anuj before Aditya
•	Append the name Saras
•	Delete (Avi) from the list
•	Replace anil with Anil Kumar
•	Sort all the names
•	Reverse the list
•	Length of the list """
#Create list of 5 name as above question  
naming_list=["Anil","Anmol","Aditya","Alka","Avi"]
print("Here is the list of 5 users:",naming_list) #print name list
# using insert() to append  name Anuj before Aditya 
naming_list.insert(2,"Anuj")
print("Here is the 6 users",naming_list) #print new name list
#Append the name Saras in list and print list
naming_list.append("Saras")
print("Here is the list with append:",naming_list)
#Delete (Avi) from the list and print list
naming_list.remove("Avi")
print("Here is the list after remove Avi:",naming_list)
#Replace anil with Anil Kumar and print list
naming_list[0]=("Anil Kumar")
print("Here is the list after replace name:",naming_list)
#Sort all the names  and print
naming_list.sort()
print("Here is the list after sort name:",naming_list)
#Reverse the list and print
naming_list.reverse()
print("Here is the list after reverse name:",naming_list)
#Length of the list and print
length_list=len(naming_list)
print("Length of list:",length_list)
Leave a Comment