[Python] Writing a range loop to file [closed]

Discussão em 'Python' iniciado por Stack, Julho 15, 2025.

  1. Stack

    Stack Membro Participativo

    Below is my code. All I am trying to do is write to the file in the format that the code prints. I have tried all sorts and best I can get is the final number 17570 in the file. Clearly something wrong in the f.write, any suggestions?

    print("creating Table")

    nums = range(17501, 17570)
    for i in range(0, len(nums),):
    print (nums, "1", "1", "1", "1")

    F = open("new.txt", "w")
    f.write(nums, "1", "1", "1", "1")

    Continue reading...

Compartilhe esta Página