I\'m new to python.
I want the program to ask
\"is Johnny hungry? True or false?\"
user inputs True
then print is
you can use a simple helper that will force whatever input you want
def get_bool(prompt):
while True:
try:
return {"true":True,"false":False}[input(prompt).lower()]
except KeyError:
print "Invalid input please enter True or False!"
print get_bool("Is Jonny Hungry?")
you can apply this to anything
def get_int(prompt):
while True:
try:
return int(input(prompt))
except ValueError:
print "Thats not an integer silly!"