Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Lists Build an Application Display the List

IF / ELIF statement

So as we check new_item to see if it matches DONE, SHOW, or HELP, I've been doing it as shown below.

if new_item.upper() == "DONE":
    break

elif new_item.upper() == "HELP":
    show_help()
    continue

elif new_item.upper() == "SHOW":
    show_list()
    continue

Is there any downside to this, or is it just personal flavour? My reasoning behind it is if they do it lower case or in weird casing, but does this open me up to bugs further down the road? I've tested it by adding things like: 'TV SHOW' and 'well done roast beef' and it seems fine.

-Carter

Jerry Kankelborg
Jerry Kankelborg
4,885 Points

i would add the upper() method to the input() to avoid bugs in the future, like so :

new_item = input("> enter command: ").upper() if new_item == 'DONE': break

1 Answer

Steven Parker
Steven Parker
229,657 Points

Making command words case-insensitive is a common practice, and a nice enhancement to the project. :+1: