Im trying to write a text file from a list, it works perfectly with a list of strings, each element gets on a new line. But when I try to write from a list with integers it does
#!/usr/bin/python years = [1,2,3,4,5,6,7,8,9,10] with open('year.txt', 'w') as file: for year in years: file.write("%i\n" % year)
gives
$ cat year.txt 1 2 3 4 5 6 7 8 9 10
Is that what you want?