shoplist=['apple','milk','pen'] print(shoplist) print(shoplist[0]) print(len(shoplist))
#可直接改 shoplist[2]='eggs'
print(shoplist.index('milk'))
shoplist.append('bread') shoplist.insert(0,'butter')
#取出並移除,最後或指定第幾個 item=shoplist.pop() item=shoplist.pop(1)
shoplist.sort() print(shoplist)
for item in shoplist: print(item)
newlist=['paper','ox'] newshoplist=shoplist+newlist print(newshoplist)
list3= "2016/12/31".split('/') print(list3) print(list3[::-1]) #相反順序
list4[開始:結束:間隔]