I run this code:
file=open(filename, 'r')
line=filename.readline()
totallines=0
total=0
while line != "":
amount=float(line)
print(format(amount, '.2f'))
line=filename.readline()
totallines+=1
total+=amount
avg=total/totallines
print("The average of the numbers is", format(avg, '.2f'))
and it gives me this error AttributeError: 'str' object has no attribute 'read'
I dont understand what Im doing wrong?
filenameis a string. you should dofile.readline()