x = int (raw_input('Introduceti Ziua in care doriti adaugarea: '))
print
print " Options Available"
print "---------------------------------"
print "1 -- FOOD"
print "2 -- BOOKS"
print "3 -- SPORTS"
print "4 -- Clothing"
print "5 -- Transport"
y = int (raw_input('Introduceti tipul dorit: '))
m = int (raw_input('Introduceti valoarea dorita: '))
a[x][y]=a[x][y] + m
这是我的功能之一。a
是全局的,定义为所有值都设置为 0 的矩阵,例如a = [[0,0,0,0,0],[0,0,0,0,0,0]]
. 如果我尝试a[1][2] = a[1][2] + m
,我会看到错误消息List index out of range
。
请帮忙。