I need to generate a file, where each line is a concatenation of a sentence (template) and four variables. Those four variables(their values respectively) have previously been collected in separate lists. So far I have tried:
num = [1,2,3]
fruit = [grape ,banana,pea]
fruits = [grapes, bananas, peas]
with open('result', 'w') as r:
for n,f,g in num,fruit,fruits:
r.writelines("This is string number %d. This is a %s. And I like to eat %s" % (num[n],fruit[f],fruits[g]))
...this approach raises :
TypeError: list indices must be integers, not tuple.
I am also failing at "mungling" this together with different lists, i.e. first concat the first and second variable + string with an intermediate list, to reduce "complexity".
Could someone give me a hint at where i'm failing?