我有以下代码:
iva_versamenti_totale={'Liquidazione IVA': [sum(t) for t in zip(*iva_versamenti.values())],}
utilizzato=dict()
riporto=dict()
utilizzato['Key_1']=list(0 for m in range(13))
riporto['Key_2']=list(0 for m in range(13))
for index, xi in enumerate(iva_saldo_totale['Saldo IVA'], 0):
if xi > 0 :
riporto['Key_2'][index] = riporto['Key_2'][index] + xi
else:
riporto['Key_2'][index] = riporto['Key_2'][index-1]-utilizzato['Key_1'][index]
for index, xi in enumerate(iva_saldo_totale['Saldo IVA'], 1):
if xi > 0 :
utilizzato['Key_1'][index] == 0
elif riporto['Key_2'][index-1] >= xi:
utilizzato['Key_1'][index] = - xi
else:
utilizzato['Key_1'][index]=riporto['Key_2'][index-1]
但是Python给我以下错误:
IndexError: list assignment index out of range
I want that the for loop start from the second element of each variable (riporto
, utilizzato
and iva_versamenti_totale
) in such a way that I can set manually these first values.