Home  >  Article  >  Backend Development  >  python program Lists

python program Lists

PHPz
PHPzOriginal
2024-08-28 18:31:03998browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn