0

I am trying to open a file in python but I keep getting the error "an integer is required"

My code:

    print("This is console module")

    import random

    def randomNumber(myFile):


    times=0

    print("Generating numbers...")

       while times != 10:
           random=random.randint(1, 100)
           print("\nNumber generated: "+str(random))
           myFile.write(random)
           times+1

       myFile.close()
       print("Done")




   myFile = open("NUMBERS.TXT", "a", "wt", "rt")

   randomNumber(myFile)

   myFile.close()

I want it to print random numbers to a file

0 Answers0