I want to write a program that calculates the GPA of given number of subjects. First the program will prompt the user to enter the number of subjects and then ask "What is the name of class 1?" for the first class and for the second class, it will ask "What is the name of class 2?"
Here, I want to use loop to change the number from 1 to number of classes the user enter. But I cannot increase the number in a 'input' statement.
def main():
names= []
grades = []
number_classes = int(input("How many classes did you take? "))
print()
for i in range(1, number_classes + 1):
p = input("What is the name of class 1? ")
names.append(p)
q = input("What grade did you get in that class? ")
grades.append(q)
I have attached my piece of code. It asks "What is the name of the class 1? " each time. How can I increase it 1 to 2 to 3 each time it loops?