Grading program having problems with while loop and using different data types
<p>I'm making a program where I need to have the user input a series of homework grades (ranging from 0 to 10) until they type 'done' in which case I must calculate the average of the scores and provide a corresponding letter grade. My trouble is, I don't know how to calculate the average when I don't have the exact number of homeworks to divide the sum of all of the homeworks by, since it's not on a finite loop. And also, when I run my program I keep getting an error message that says TypeError: unorderable types: str() &lt; int()</p>

<p>Here's my code so far:</p>

<pre><code>    print("Enter your homework scores one at a time, must be an integer ranging from 0 to 10. When finished, type done.")
number=input("Enter your homework grade: ")

while number != 'done':
    number=input("Enter your homework grade: ")
    percentage= number*10 #I need to divide by number of homeworks there are, but I'm not sure how to get the variable I need to divide by.

    if number &lt; 0 or number &gt; 10:
        print("Score must be between 0 and 10")
    elif percentage &gt;= 92 and number &lt; 100:
        letter = 'A'
    elif percentage &gt;= 87 and number &lt; 92:
        letter = 'B+'
    elif percentage &gt;= 80 and number &lt; 87:
        letter = 'B'
    elif percentage &gt;=77 and number &lt; 80:
        letter = 'C+'
    elif percentage &gt;=70 and number &lt; 77:
        letter = 'C'
    elif percentage &gt;= 67 and number &lt; 70:
        letter = 'D+'
    elif percentage &gt;= 60 and number &lt; 67:
        letter = 'D'
    elif percentage &lt; 60 and number &gt;= 0:
        letter= 'F'
    elif number == 'done':
        print(percentage,"%, you got an ", letter)
    else:
        print("Error: please enter an integer ranging from 0 and 10.")
</code></pre>

<p>Outside of your <code>while</code> loop, you can keep an array of grades you've seen so far. It will start out empty. </p>

<pre><code>arr = []
</code></pre>

<p>Every time you see a new grade, you can append it to the array. </p>

<pre><code>newGrade = input("Enter your homework grade")
arr.append(float(newGrade)*10)
</code></pre>

<p>Once the user enters done, you can calculate the average using the <code>sum</code> and <code>len</code> functions, which give you the sum of the elements in the array and the number of elements in the array, respectively. </p>

<pre><code>average = sum(arr)/len(arr)
</code></pre>

python