The program in Listing 8.8 only executes correctly the first time. If you enter anything but 3 the first time it will end the program. If you enter 3 at the first prompt, you can enter anything you want at the subsequent prompts and it will continue the loop until you interrupt. A more appropriate program would be:
someInput = int(input("Type 3 to continue, anything else to quit."))
while someInput == 3:
(indent)print ("Thank you for the 3. Very kind of you.")
(indent)someInput = int(input("Type 3 to continue, anything else to quit."))
(indent)if someInput != 3:
(indent)(indent)print ("That's not a 3, so I'm quitting now.")
|