From 64b582fa6f46cd02b0c52fabb5c80b87f3c064a4 Mon Sep 17 00:00:00 2001 From: David Avery Date: Wed, 29 Jan 2020 13:54:51 +0000 Subject: [PATCH] Lesson 59 --- basics.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/basics.py b/basics.py index acdfd99..e39230f 100644 --- a/basics.py +++ b/basics.py @@ -1,7 +1,18 @@ -output = "" -something = "" -while something != "\end": - something = input("Say something: ") - if something != "\end": - output = output + something + ". " -print(output) \ No newline at end of file +def sentence_maker(phrase): + interrogatives = ("how", "what", "why") + capitalized = phrase.capitalize() + if phrase.startswith(interrogatives): + return "{}?".format(capitalized) + else: + return "{}.".format(capitalized) + +results = [] +while True: + user_input = input("Say something: ") + if user_input == "\end": + break + else: + results.append(sentence_maker(user_input)) + +print(" ".join(results)) + \ No newline at end of file