buat senarai saya
mylist=["singam","goat","rayyan","leo"]
print(mylist)
print(mylist[2])
mylist[1]="mersal"
print(mylist)
mylist=["singam","kambing","raayan"]
mylist.append("mersal")
print(mylist)
mylist=["singam","kambing","raayan"]
mylist.insert(1,"Mersal")
print(mylist)
mylist=["singam","kambing","rayaan","mersal"]
mylist.remove("singam")
print(mylist)
mylist=["singam","kambing","rayaan","mersal"]
untuk x dalam senarai saya:
cetak(x)
mylist=["singam","kambing","rayaan","mersal"]
mylist.sort()
print(mylist)
mylist=["singam","kambing","rayaan","mersal"]
mylist.pop()
print(mylist)
o/p
['singam', 'kambing', 'rayyan', 'leo']
rayyan
['singam', 'mersal', 'rayyan', 'leo']
['singam', 'kambing', 'raayan', 'mersal']
['singam', 'Mersal', 'kambing', 'raayan']
['kambing', 'rayaan', 'mersal']
singam
kambing
rayaan
mersal
['kambing', 'mersal', 'rayaan', 'singam']
['singam', 'kambing', 'rayaan']
Atas ialah kandungan terperinci Senarai program python. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!