-2

例如,如果我有这个开始:

Movies = [["Sixth sense"],["Austin Powers 2"],["Ted"],["Lethal weapon"],["Paul"],["Die hard"],["Kick ass"],["Avengers"],["I am legend"],["Matrix"]]
Choice = int(input("Which movie do you want to see?"))
print (Movies[Choice])

我如何要求用户删除他们不喜欢的电影?

4

1 回答 1

0

给定

Movies = [["Sixth sense"],["Austin Powers 2"],["Ted"],["Lethal weapon"],["Paul"],["Die hard"],["Kick ass"],["Avengers"],["I am legend"],["Matrix"]]

我假设他们选择了#4(他们选择了一个数字,所以我假设按索引删除),

Choice = 4

请注意,第 4项不是but'Paul'['Paul']

Movies[4]
#>>> ['Paul']

您可以在该索引处删除

del Movies[4]

Movies
#>>> [['Sixth sense'], ['Austin Powers 2'], ['Ted'], ['Lethal weapon'], ['Die hard'], ['Kick ass'], ['Avengers'], ['I am legend'], ['Matrix']]
于 2013-09-19T15:03:59.847 回答