Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_answer(prompt):
- retval = {'yes': True, 'no': False}
- while True:
- answer = input(prompt).strip().lower()
- # in operator looks up the keys in a dictionary
- if answer in retval:
- # returns the value of the key
- return retval[answer]
- print(get_answer('yes / no: '))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement