Hello all. I am very excited to have found this place in that I might better my very shoddy coding skills. I am trying to learn Python with a couple of books and some ideas for programs. I am trying to figure out a matter of what I think is an output formatting issue.
file=open('c:\\Users\\Minus\\Desktop\\PyTest.txt', 'w')
for i in range(0, 105, 5):
print(i, end=" ")
j=str(i)
file.write(j)
file.close()
What I am trying to accomplish, is to output the result of the code to a text file. While this code will output the integers within my range, it does it like this 05101520253035404550556065707580859095100
I am simply trying to make the output of the code cleaner by inserting a space between integers. I am pretty convinced that my code is overkill for what I am trying to do and that it is a simple fix. I have searched for a solution, but have not found what I think is the right answer and am hoping someone here can give me a hand.
I have looked at string formatting and thought of making a list and then using replacement fields, but it seems like printing 20 elements is more work than being able to insert a space.
My questions are: can I simply insert a space into the output, if so, how? Is there a better, cleaner way to execute this code?
I am still very green with regard to Python and do appreciate any help.
W.C