Need help dividing string by input

I am working on Python and am writing a program where the user inputs how many courses they would like to calculate. Then the program is supposed to take the appended items (the strings) and then divide them by how many courses they would like, in other words the total (integer). I cannot seem to figure out a way to implement this properly, any help? The issue is under If value = 1.

def List ():
    print("Please make your selection in accordance with the numbered list:\n")
    print("1. Add Grades")
    print("2. Print current GPA")
    print("3. Exit")
    return int(input())

print("Thank you for using the text-based UCF GPA calculator! How can we assist you today?\n")

#Empty lists
grades = []

value = 0

while (value != 3):
    for i in range (0,1):
        value = List ()

    if (value == 1):
        selection = int(input("How many classses would you like to include?\n"))
        for i in range (0,selection):
            print("What is the grade of the class?")
            item = (input())
            GPA_list = [sum(item)/selection for i in grades]
    elif(value == 2):
    elif(value == 3):
        print("Thank you for using the UCF GPA calculator, have a great day!")
        print("Sorry, that input is not recognized")

instead of if (value == 1) try if value == 1. I don’t really know why your code did not work, but as per my guesses I think so python is treating (value == 1) as a tuple(and it should, if there’s some exception/error post it over here, it will help in finding the problem) and if you do so it will always return True.

Let us see what happens. I fixed selection before and than started:

>>> grades = []
>>> selection = 2
>>> item = input()
>>> sum(item)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> item

I input the value for item and it answers that we cannot do + on a comnbination of int and string.

Maybe this?

>>> item = input()
>>> item
>>> sum(item)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'

That still is a string.

Next step:

>>> item = int(item)
>>> sum(item)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable

We transform the input (the string 54) to an int and now the error changes to TypeError: 'int' object is not iterable. Why? We go to the docs for sum and read:

sum ( iterable , / , start=0 )

Sums start and the items of an iterable from left to right and returns the total. The iterable ’s items are normally numbers, and the start value is not allowed to be a string.

Your description of the wanted result is:

This must be an incorrect statement as we have seen

  • A string cannot be summed
  • A string cannot be divided by a number.

From the program code I infer that the grade must be a number and the program needs to check if a combination of classes is sufficient for some threshold. So sum the grades after all grades have been input and not for each entry, something like this:

>>> for i in range(selection):
...    a = int(input("Grade:"))
...    grades.append(a)
>>> grades
[4, 6]
>>> print("Average grade", sum(grades)/selection)
Average grade 5.0