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) Number Game App Number Game Refinement

Why do we lowercase play_again @ 7:55?

At 7:55.

play_again 

is lowercased to

play_again.lower()

I tested it out without lower() and it seemed fine? Whats the use of this?

2 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Ryan,

This is just to make the input case insensitive. The user can enter n or N and the app will quit correctly. If you don't have lower(), then it makes the user input case sensitive.

Hope that makes sense!

Cheers :beers:

-Greg

Greg Kaleka Wouldn't lower() make it case sensitive due to only lowercase answers being allowed?

Greg Kaleka
Greg Kaleka
39,021 Points

It's the opposite. You're checking if the answer was 'n'. If you don't lowercase the input then 'N' won't match. 'N' == 'n' is False. If you do lowercase the input, then both 'n' and 'N' will be accepted answers. 'N' turns into 'n' and 'n' stays as it is. Then you check 'n' == 'n' in both cases which is True. Make sense?

Ari Misha
Ari Misha
19,323 Points

Hiya again! Can you paste the whole code here please? So that other people can inspect it. (:

I suggest to just check out the code @ 7:55.. It's quite hassle for me to write the whole code all over again... is that okay?