how do i write the numbers on separate lines?

Researching a bit about file handlers, escape strings and for loops would be useful:

with open("numbers.txt", "wt") as f:
    x = 1
    for i in range(10):
        x += 1
        f.write(str(x)+'\n')

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top