2024-06-06 07:03:49 发布
网友
给出TypeError且不确定原因,希望输入的索引删除列表中的一个点:
x = input('Which part of the list would you like to remove?(index starts at 0):') myThing.pop()[x] print(myThing)
x = input('Which part of the list would you like to remove?(index starts at 0):') myThing.pop(int(x)) print(myThing)
pop将要删除的索引作为参数,因此可以在.pop后面的括号中传递它。此外,还需要将输入转换为int,因为input()返回str
.pop
int
input()
str
pop将要删除的索引作为参数,因此可以在
.pop
后面的括号中传递它。此外,还需要将输入转换为int
,因为input()
返回str
相关问题 更多 >
编程相关推荐