《Python编程:从入门到实践》列表增删元素实践

《Python编程:从入门到实践》列表增删元素实践_第1张图片
《Python编程:从入门到实践》列表增删元素实践_第2张图片

list = ["sam","tom","mike","paul"]
print(list.pop(0))
list.append("ela")
print(list)
print("A blgger table is found.")
list.insert(0,"sia")
list.insert(2,"ryan")
list.append("hipp")
print(list.title())
print("because of the lack of table, only tow guests can be invited.")
print("it`s a pity that {} can`t come to the party".format(list.pop()))
print("it`s a pity that {} can`t come to the party".format(list.pop()))
print("it`s a pity that {} can`t come to the party".format(list.pop()))
print("it`s a pity that {} can`t come to the party".format(list.pop()))
print("it`s a pity that {} can`t come to the party".format(list.pop()))
print(list)
del list[0]
del list[0]
print(list)

你可能感兴趣的:(《Python编程:从入门到实践》列表增删元素实践)