I have a list that contains 5 variables, say:
list2=[1,2,3,4,5]
and I have a list of dict with 5 key-value pairs, which I initialized to be :
list1[i]= {"input1": 0, "input2": 0, "input3": 0, "input4": 0, "input5": 0}
I want to iterate over the dict and list so that in each iteration, I will replace the value of a key in the dict with the value from the list, so the dict will become:
list1[i]= {"input1": 1, "input2": 2, "input3": 3, "input4": 4, "input5": 5}
Currently, I use this to iterate over the dict and list:
def Get_Param(self):
self.list1=[]
inputcount=0
for line in self.textBox.get('1.0', 'end-1c').splitlines():
if line:
self.list1.append({'input1':0, 'input2':0, 'input3': 0, 'input4': 0, 'input5': 0})
list2=[int(i) for i in line.split()]
for parameter, value in zip(self.list1[inputcount], list2): //exception is thrown here
self.list1[inputcount][parameter]=value
inputcount+=1
but it keeps returning "list indices must be integers, not Unicode" exception. Can anyone suggest a better idea to do this or tell me in which part of the code I did wrong?