Posts: 1,298
Threads: 38
Joined: Sep 2016
What is your question? You may want to start by checking the spelling of one of your variables.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Posts: 1,298
Threads: 38
Joined: Sep 2016
Oct-04-2016, 03:19 PM
(This post was last modified: Oct-05-2016, 09:58 AM by snippsat.)
I always find it helpful to add "print()" statements at various points to verify that the value of variables are what they should be.
You have the line:
morestudents = input("Do you have any students? (yes/no) ").lower()
What happens if you enter "no", you have nothing so far to handle that and will end up with an error.
If you enter "yes", you progress to your first "while" statement which says if morestudents == 'yes', ask for a score.
Since nothing ever changes the value of 'morestudents' you will be stuck in this loop forever and you will not progress to the rest of your script.
Here is one simple example of using a 'while' loop:
while True:
number = int(input("enter a number between 1 and 10: ")) # Get a number
if 0 <= number <= 10:
print("number = ", number)
# Go back and get another number
else:
print("out of range")
break # Break out of 'while' loop and continue with next command
print("Done")
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition