Home > Article > Backend Development > python program Lists
mylist create
mylist=["singam","goat","rayyan","leo"]
print(mylist)
print(mylist[2])
mylist[1]="mersal"
print(mylist)
mylist=["singam","goat","raayan"]
mylist.append("mersal")
print(mylist)
mylist=["singam","goat","raayan"]
mylist.insert(1,"Mersal")
print(mylist)
mylist=["singam","goat","rayaan","mersal"]
mylist.remove("singam")
print(mylist)
mylist=["singam","goat","rayaan","mersal"]
for x in mylist:
print(x)
mylist=["singam","goat","rayaan","mersal"]
mylist.sort()
print(mylist)
mylist=["singam","goat","rayaan","mersal"]
mylist.pop()
print(mylist)
o/p
['singam', 'goat', 'rayyan', 'leo']
rayyan
['singam', 'mersal', 'rayyan', 'leo']
['singam', 'goat', 'raayan', 'mersal']
['singam', 'Mersal', 'goat', 'raayan']
['goat', 'rayaan', 'mersal']
singam
goat
rayaan
mersal
['goat', 'mersal', 'rayaan', 'singam']
['singam', 'goat', 'rayaan']
The above is the detailed content of python program Lists. For more information, please follow other related articles on the PHP Chinese website!