[Tutor] tiny, little issue with list

Rafael Knuth rafael.knuth at gmail.com
Sun Mar 19 08:17:03 EDT 2017


LogActivities = []
prompt = ("What have you done today? ")
prompt += ("Enter 'quit' to exit. ")

while True:
    activity = input(prompt)
    LogActivities.append(activity)

    if activity == "quit":
        print("Let me recap. This is what you've done today: %s." % ",
" .join(LogActivities))

This program is supposed to take user input and to log his activities
into a list.
All works well, only when the user quits, the program adds 'quit' to
LogActivities.
How do I prevent my program from doing this?

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900
32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
= RESTART: C:/Users/Rafael/Documents/01 - BIZ/PYTHON/Python Code/PPC_159.py =
What have you done today? Enter 'quit' to exit. shower
What have you done today? Enter 'quit' to exit. walk the dog
What have you done today? Enter 'quit' to exit. drink coffee
What have you done today? Enter 'quit' to exit. prepare lunch
What have you done today? Enter 'quit' to exit. take coding lesson
What have you done today? Enter 'quit' to exit. quit
Let me recap. This is what you've done today: shower, walk the dog,
drink coffee, prepare lunch, take coding lesson, quit.
What have you done today? Enter 'quit' to exit.


More information about the Tutor mailing list