I have these two list group_name and group_ids_list im looping these two list and I want to do an if condition based on the group id of this list. I want to know if there is a way to do this if groupId == 0: dynamically because this current example wont scale very well if I keep adding more groups and so on.
group_name = ['a','a','b','c', 'a', 'd']
group_ids_list = [0,0,1,2,0,3]
for groupName, groupId in itertools.zip_longest(group_name, group_ids_list):
if groupId == 0:
print('found group 0 name is {}'.format(groupName))
elif groupId == 1:
print('found group 1 name is {}'.format(groupName))
elif groupId == 2:
print('found group 2 name is {}'.format(groupName))
group_idsreally supposed to be the indexes or is it supposed to be the values found ingroup_ids_list?