This repository has been archived on 2023-11-08. You can view files and clone it, but cannot push or open issues or pull requests.
How-To-Git-Started/assignments/icecream.py

15 lines
411 B
Python
Raw Normal View History

2020-01-16 11:13:36 +01:00
def ask_yes_no(prompt):
while True:
answer = input(prompt + ' (y or n) ')
if answer == 'y' or answer == 'Y':
return True # returning ends the function
if answer == 'n' or answer == 'N':
return False
print("Answer 'y' or 'n'.")
if ask_yes_no("Do you like ice cream?"):
print("You like ice cream!")
else:
print("You don't like ice cream.")