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 trialAli AlRabeah
909 PointsHow 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
231,248 PointsThe "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
909 PointsAli AlRabeah
909 PointsAh, that makes sense. It's all because it's a comparison (==). Appreciate it.