How to calculate user input in python
<p>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.</p>

<p>This is what I have so far:</p>

<pre><code>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()
</code></pre>

<p>Whenever I enter "done," the program gives me this error.</p>

<blockquote>
  <p>TypeError: 'int' object is not iterable</p>
</blockquote>

<p>I have tried changing the user_input variable to :</p>

<blockquote>
  <p>user_input = int(input("Enter grade: "))</p>
</blockquote>

<p>But, another error: TypeError: </p>

<blockquote>
  <p>'int' object is not iterable user input</p>
</blockquote>

<p>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.</p>

<p>I am noticing some things which may solve the issue for you.</p>

<ol>
<li>You're feeding <code>number</code> to the <code>avg</code> function when really you want to give it a list of numbers.</li>
<li>I think you should do something like this: make a list called numbers and append each user input to that list. Then use the avg function on the numbers list.</li>
</ol>

python input