IndexError: list assignment index out of range in python What am i doing wrong. I am an newbie
actual_ans_dict = []
for data in prsnobj.result:
actual_ans_dict[data[0]] = data[1]
print actual_ans_dict
actual_ans_dict is an empty list. You are trying to set a value to actual_ans_dict[data[0]] but an element with this index doesn't exist.
You can change the type of actual_ans_dict to dict:
actual_ans_dict = {}
for data in prsnobj.result:
actual_ans_dict[data[0]] = data[1]
print actual_ans_dict
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With