【发布时间】:2018-03-21 11:31:19
【问题描述】:
list1 = [1,2,3,4,5]
list2 = list1.insert(-1, 100)
list2 = [1,2,3,4,100,5]
我不明白为什么结果会像上面那样, 但现在我明白了。 谢谢大家,我真的是。
【问题讨论】:
-
insert()函数在len(list) - position处插入值。 -
Negative list index?的可能重复
-
你可以尝试不同的负值吗? -2, -3, -4, -5 ?检查结果,你会得到答案。祝你好运。
-
@zolv 试错并不是学习编程的最佳方式。阅读文档更好。