I want to run a list of functions, where each function should take one item from a list as parameter.
Func1 parameter takes first list value, Func2 parameter takes second list value...and so on.
So far, I have the following:
main.py
#import the 5 python files
import sheet_1 as s1
import sheet_2 as s2
import sheet_3 as s3
import sheet_4 as s4
import sheet_5 as s5
#save the functions in a list
func_lst = [s1.func1, s2.func2, s3.func3, s4.func4, s5.func5]
#save workbook key as list
sheet_lst = ["Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5"]
sheet_1.py
def sheet1(n): #n param should take "Sheet1"
print(n*2) #prints "Sheet1Sheet1"
sheet_2.py
def sheet2(n): #n param should take "Sheet2"
print(n*2) #prints "Sheet2Sheet2"
sheet_3.py
def sheet3(n): #n param should take "Sheet3"
print(n*2) #prints "Sheet3Sheet3"
And so on...
To make it more visual, this is how the code should look/work like:
#for first iteration
for item in sheet_lst: #take "Sheet1"
for f in func_lst: #take s1.func1
f(item) #run function with item parameter.
The end result of the loop would be:
s1.func1("Sheet1");
s2.func2("Sheet2");
s3.func3("Sheet3");
s4.func4("Sheet4");
s5.func5("Sheet5");
Does anyone have any clue on how to structure the loop?
Thanks in advance!
func_lstand list of sheetswbkey, are you trying to apply first functionfunc_list[0] to wbkey[0], func_list[1] to wbkey[1],...etc.?