python:list index out of range

学习 时间:2026-08-24 17:46:54 阅读:9530
python:list index out of range给序列num排序,num是一组数字组成的序列 m=0 while m

最佳回答

怕孤独的冥王星

活泼的云朵

2026-08-24 17:46:54

遇到这种情况 不妨把它打印出来:num=[2,3,4,6,1]m=0 while m> 1234Traceback (most recent call last): File "C:\Documents and Settings\Administrator\妗岄溃\1。py", line 4, in IndexError: list index out of range这样你可以知道了把,在m=4的那个循环那里出了问题,因为这个序列长度为5,它不可能有num[5]的情况,就叫做溢出了(list index out of range),所以在if num[m]

最新回答共有2条回答

  • 魁梧的未来
    回复
    2026-08-24 17:46:54

    遇到这种情况 不妨把它打印出来:num=[2,3,4,6,1]m=0 while m> 1234Traceback (most recent call last): File "C:\Documents and Settings\Administrator\妗岄溃\1。py", line 4, in IndexError: list index out of range这样你可以知道了把,在m=4的那个循环那里出了问题,因为这个序列长度为5,它不可能有num[5]的情况,就叫做溢出了(list index out of range),所以在if num[m]

上一篇 指出下面句中的通假字1.诎右臂支船2.左手倚一横木3.长约八分有奇

下一篇 if only虚拟语气从句只有两种变化形式?