Skip to content

Instantly share code, notes, and snippets.

@macagua
Last active December 12, 2015 03:48
Show Gist options
  • Save macagua/4709197 to your computer and use it in GitHub Desktop.
Save macagua/4709197 to your computer and use it in GitHub Desktop.
A example for try to fixing user input from Python script
# -*- 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