Sep-26-2021, 09:06 PM
Hi,
I'm trying to create a dictionay combining 2 arrays but I just cannot get it right.
The end result should be: EDITED:
I'm trying to create a dictionay combining 2 arrays but I just cannot get it right.
The end result should be: EDITED:
{'in_ledS':0, 'in_ledXL':1, 'in_ledXXL':0, 'in_ledS1':1, 'in_ledS2':1}I appreciate some help.
#leds status as input in_ledS = 17 #pin 11 in_ledXL = 18 #pin 12 in_ledXXL = 22 #pin 15 in_ledS1 = 23 #pin 16 in_ledS2 = 4 #pin 7 leds_arry = [in_ledS, in_ledXL, in_ledXXL, in_ledS1, in_ledS2] leds_state = [0, 1, 0, 1, 1] def create_dict(): leds_dict = {} for i in range(len(leds_arry)): leds_dict[i] = leds_arry[i] + leds_state[i] print(leds_state) #or x = dict(zip(leds_arry, leds_state)) print(x)