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 All Together Now Branch and Loop

Ali AlRabeah
Ali AlRabeah
909 Points

How come the lowercase method allows for capitalized and lowercase "yes" answers?

Pretty interesting. In:

proceed = input("Do you want to proceed? Yes or No.  ")
if proceed.lower() == "yes":
    print("SOLD!")

By just looking at it I would assume that the input for proceed would have to be "yes" instead of "Yes" or "YES".

1 Answer

Steven Parker
Steven Parker
231,268 Points

The "lower" method changes all capital letters to lower case, so the comparison can then match no matter what case was input. For example, if you do this:

print("YES".lower())  # you will see: yes
print("Yes".lower())  # you will also see: yes
Ali AlRabeah
Ali AlRabeah
909 Points

Ah, that makes sense. It's all because it's a comparison (==). Appreciate it.