I want to run a function that will create a file with the name of a variable and write in it the content of that variable.
list_A = 'one two three'.split()
def write_list(list_to_write):
flux = open('%s.list' %list_to_write, 'w')
flux.write('\n'.join(list_to_write))
flux.close()
write_list (list_A)
This creates a file called ['one', 'two', 'three'].list
I would like it to create a file called liste_A.list
instead.
PS: I found many similar posts, but none that seemed to address my issue.