I have an assignment that is very similar to a past assignment. I have to create a for loop to find gpa.
The previous assignment was to use a while loop:
stop1 = int(input('How many GPAs do want to calculate? '))
totalgp = 0
totalgp1 = 0
while stop1 > 0 :
stop = int(input('Enter the number of classes you have: '))
while stop > 0:
grade = input('Enter the grade recieved: ')
if grade == 'A':
grade = 4
elif grade == 'B':
grade = 3
elif grade == 'C':
grade = 2
elif grade == 'D':
grade = 1
else:
grade = 0
units = int(input('Enter the amount of units for that class: '))
GP = grade * units
totalgp += GP
totalgp1 += units
stop -= 1
GPA = round(totalgp/totalgp1, 2)
print('Gpa: ', GPA)
stop1 -= 1
I need to convert the two while loops into for loops, but i dont quite understand for loops. Help would be much appreciated