I have a problem with a litlle program in python: what I want is to write on a archive called text numbers from 0 to 10, but the program give me error all the time and doesn't print anything.
i=0
while(i<11):
outfile = open('text.txt', 'a')
outfile.write('\n'+i)
outfile.close()
i=i+1
I tried puting
outfile.write('\n'+i)
outfile.write('\n',i)
outfile.write('\n'),i
outfile.write(i)
but not a single one of them works, can you tell me what I am doing wrong please?
I'm guessing that the error you're getting involves concatenating a string with an integer.
try:
outfile.write(str(i) + '\n')