I am trying to write two functions. One generates random numbers between 1 and 100 with the parameter being the frequency of numbers which saves the information to a file, and another one reads this file and displays the: total sum, average, highest and lowest value. I have managed to get the first function to work however the secound function does not. When running the program I get the TypeError: 'int' object is not iterable due to the "number=int(number)" line in the readNumbers() function, which I don't understand because I thought the number had to be changed from a string to an int in order for equations to work. Any help would be appreciated. Also is there a method of finding the maximum and minimum values without using max() and min(), I would personally like to know.
def generateNumbers(i):
myFile=open("numbers.txt","w")
for n in range(i):
import random
numbers=random.randint(1,100)
numbers=str(numbers)
myFile.write(numbers)
myFile.close()
generateNumbers(400)
def readNumbers():
myFile=open("numbers.txt","r")
for number in myFile:
number=int(number)
total=(sum(number))
average=sum/float(len(number))
while number!=-1:
num_list.append(number)
high= max(num_list)
low= min(num_list)
print(total,average,high,low)
myFile.close()
readNumbers()