I have dictionary called nested_group_map based on 4 groups each with a key called shed_count in each group. How could I make a program that will add +1 to each shed_count in a range loop fashion by iterating through the nested_group_map keys/values and then break when the number of cycles through the range loop is complete? Basically what I am thinking is the shed_count in each group should == cycles which 12.
Sorry sort of an odd question, hopefully this makes sense.
import numpy as np
cycles = 12
nested_group_map = {
'group_l1n' : {
'shed_count': 0,
},
'group_l1s' : {
'shed_count': 0,
},
'group_l2n' : {
'shed_count': 0,
},
'group_l2s' : {
'shed_count': 0,
}
}
def cycle_checker(cycles):
check_sum = [int(cycles)]
print(f'cycle_checker after for loop sum is {sum(check_sum)}')
print(f'cycle_checker appended after for loop is {check_sum}')
for group in nested_group_map:
for k,v in nested_group_map[group].items():
if k in ('shed_count'):
check_sum.append(int(v))
print(f'cycle_checker after for loop sum is {sum(check_sum)}')
print(f'cycle_checker appended after for loop is {check_sum}')
return np.all(check_sum)
while not cycle_checker(cycles):
for group in nested_group_map:
for v in nested_group_map[group].values():
v = v + 1
print(v)
This just creates an infinite loop, any newbie tips appreciated : )