python: IndexError: list index out of range
J'ai une error d'index avec ma fonction split_data_into_reg_entries
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| def split_data_into_reg_entries(data):
lst = []
if data["Register_number"]:
command_address_list = []
response_address_list = []
for i in range(0, len(data['command_address'])):
for j in range(0, data['word_count'][i]):
command_address_list.append(data['command_address'][i])
response_address_list.append(data['response_address'][i])
mapped = list(zip(data["Register_number"], data['Register_value'], command_address_list, response_address_list))
for reg, value, cmd_addr, res_addr in mapped:
tmp = data.copy()
tmp['Register_number'] = reg
tmp['Register_value'] = value
tmp['command_address'] = cmd_addr
tmp['response_address'] = res_addr
lst.append(tmp)
else:
lst.append(data)
return lst |
Voici l'erreur :
Code:
1 2 3 4 5 6 7
| File "main.py", line 370, in <module>
main()
File "main.py", line 359, in main
for item in split_data_into_reg_entries(data):
File "main.py", line 161, in split_data_into_reg_entries
for j in range(0, data['word_count'][i]):
IndexError: list index out of range |
Avez-vous une idée de la raison de cette erreur :koi: ?