list.pop(obj=list[-1])
obj -- 這是一個可選引數,這個索引對應的物件將從列表中刪除
#!/usr/bin/python3 list1 = ['physics', 'Biology', 'chemistry', 'maths'] list1.pop() print ("list now : ", list1) list1.pop(1) print ("list now : ", list1)
list now : ['physics', 'Biology', 'chemistry'] list now : ['physics', 'chemistry']