I am learning Python. I am trying to create a program that will calculate my final score in college. My question is if I can end an if
loop by myself?
E.g. I want my program to repeat the question "Do you want to add a grade?" as long as the question is "yes", and as soon as the answer is no, I want my program to leave this part of my code.
What is the easiest way to do this?
noten = [] #list for grades
lp = [] #list for the weight of my different grades
p_antwort = ['y', 'yes'] #p_antwort = positive answer
n_antwort = ['n', 'no'] #n_antwort = negative answer
txt = input("Do you want to add a grade? y/n ")
if txt in p_antwort:
i = input("What grade did you get? ")
noten.extend(i)
txt_2 = input("Do you want to add another one? y/n")
if txt_2 in p_antwort:
i = input("What grade did you get? ")
noten.extend(i)