From 8ab7d1fde437c52d455ab8d9d51a620ef15cf82a Mon Sep 17 00:00:00 2001 From: Bastian Date: Thu, 16 Jan 2020 11:13:36 +0100 Subject: [PATCH] move python file to assignments --- assignments/icecream.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 assignments/icecream.py diff --git a/assignments/icecream.py b/assignments/icecream.py new file mode 100644 index 0000000..f1f4ccb --- /dev/null +++ b/assignments/icecream.py @@ -0,0 +1,14 @@ +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.") +