Last active
December 12, 2015 03:48
-
-
Save macagua/4709197 to your computer and use it in GitHub Desktop.
A example for try to fixing user input from Python script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
print "Insisting on fixing user input" | |
first = 1 | |
second = 2 | |
third = 3 | |
while 1: | |
try: | |
extra = input("What is the extra value? ") | |
break | |
except StandardError: | |
print "That's not a number. Please try again." | |
total = first+second+third+extra | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment