尝试将2D列表中的行加在一起,然后将总计的行加在一起。但是,我尝试打印的每个书都出现错误
Traceback (most recent call last):
File "list.py", line 17, in
Row_Value = Row_Value + int(numbers[I][J])
IndexError: list index out of range
没有调用打印就没有任何错误,为了使我的课程满意,我需要进行打印
# Get our list from the command line arguments
import sys
numbers= sys.argv[1:]
# Convert the command line arguments into 2d list
for i in range(0,len(numbers)):
numbers[i]= numbers[i].split(',')
# Write your code below
Row_Value = 0
Row_Memory = 0
Number_of_Rows = len(numbers)
Number_of_Columns = len(numbers[1])
for I in range(0, Number_of_Rows):
for J in range(0, Number_of_Columns):
Row_Value = Row_Value + int(numbers[I][J])
print (Row_Value)
Row_Memory = Row_Memory + Row_Value
Row_Value = 0
print (Row_Memory)
另外,添加行 打印(“ hello World”) 打印hello world和Row_Memory Fine的最终值,没有任何错误。但是,一旦我删除其他打印件,该错误又回来了。
此外,如果没有最终的打印请求,我们将得到
程序输入失败:1,1,-2 -1,-2,-3 1,1,1 预期输出:0 -6 3 -3 您的程序输出:0 -6 3
感谢您的帮助= /