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 Python Basics (2015) Letter Game App Letter Game Introduction

At 3:30 why did he put it as lower() and with 'q'?

At 3:30 he did the following... why did he do lower() and why did he make it 'q' instead of 'Q'? I don't get whats happening

while True:
    start = input("Press enter/return to start, or enter Q to quit")
    if start.lower() == 'q':
        break

Wouldn't it make sense just to do the following because it clearly stated so?

if start == 'Q'
    break
elif start == 'q'
    break

2 Answers

It is just cleaner that way. start.lower() returns the character stored in start as lowercase and then compares that lowercase character to 'q'. That way whether they type Q or q you can handle it with just one if statement.

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

Question on this topic, as I was confused on it too. Why wouldn't you just write in the variable as start.lower() = input("Q") from the start? That way it would already be lowercase no matter what? Or can you not do that because you can't put methods in as a variable name?