py4e icon indicating copy to clipboard operation
py4e copied to clipboard

quit() in try and except coding examples

Open upstate-NY-reviewer opened this issue 5 years ago • 0 comments

The video shows an example of using quit() at the end of an except block. There was no such example in the book, meaning the reader would need to replay the video to find the example. You talk about quit() earlier in the book, but not in this context. This code is my beginning of example 3.1 from the text. (NOTE: indentation is lost when I save this note - am I missing something?)

try: score = float(input("Enter Grade: ")) except: print ("Enter numerical score between 0.0 and 1.0") quit()

if (score<0.0) or (score>1.0): print ("Enter numerical score between 0.0 and 1.0") quit()

print ("Score = ", score)

upstate-NY-reviewer avatar Aug 17 '20 19:08 upstate-NY-reviewer