I am looping through several lists. Then I want to loop through their elements but each list requires different loop statements (e.g. take only every 3nd value from list 1 vs. multiply each value by 2 in list 2.).
Would it make sense to create a py file with if-elif for each list name and return list-specific loop statements? How could this be implemented? Any other ideas?
e.g.
def di_xyz(x):
if x == 'list1':
x = x+2
else:
x = x-2
newlist = []
list1 = [1,2,3]
list2 = [4,5,6]
for x in list_of_lists:
do_xyz(x)
newlist.append(x)
output:
new_list=[3,4,5,2,3,4]