I am supposed to write a program in Python that asks for grades one at a time. When the user enters “done” , calculate the following: grade average.
This is what I have so far:
def main():
user_input = input("Enter grade: ")
number = user_input
while True:
user_input = input("Enter grade: ")
if user_input == "done":
break
avg(number)
def avg(a):
average = sum(a)/len(a)
print(average)
if __name__ == "__main__":
main()
Whenever I enter "done," the program gives me this error.
TypeError: 'int' object is not iterable
I have tried changing the user_input variable to :
user_input = int(input("Enter grade: "))
But, another error: TypeError:
'int' object is not iterable user input
I am extremely new to programming. Can anyone help me work this out? I have been searching online for the past two hours and have not found anything that did not just produce another error.