I want the user to be able to terminate a nested loop by entering stop or some other keyboard input. The user is asked to enter an option a to g, followed by 8 if statements, Here is the code I wrote for the first if statement...
if option == "a":
while True:
try:
name = input('\nEnter the students name: ')
cm = input('Coursework mark: ')
em = input('Exam mark: ')
student = (name,cm,em)
database.append(student)
except :
break
I had the idea of using try and except functions but I'm not sure how or if that would work, please help!
You can check the value entered each time and if it matches your keyword (or is in a list of keywords) you
break
.For checking against a list of stop keywords, you could do something like