With the following function...
def func(listA,listB):
for i in listA:
for j in listB:
print(i+j)
...is there a way of making it dynamic so it can accept any number of lists ( func(*args)
) and still carry out the same procedure? So for example, if you provided 3 lists, it would go:
func(listA,listB,listC)
RUN:
for i in listA:
for j in listB:
for k in listC:
print(i+j+k)
4 lists:
func(listA,listB,listC,listD)
RUN:
for i in listA:
for j in listB:
for k in listC:
for l in listD:
print(l+j+k+l)
...etc
I have explored using a dictionary and while loop but i still keep facing the same issue of how to make Python aware of the lists that should be considered in the loops.