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 trialLerena Holloway
9,855 Points>>> "python" > "chocolate" this would print out as True, but I don't understand how alphabetically works
in the syntax
"python" > "chocolate"
this would print out as True, but I don't understand how alphabetically this works. I'm confused by the terminology.
3 Answers
Elias Flores
905 PointsI had this question too and after some research, this is what I've found:
Python is comparing the ASCII decimal(Dec) value of the first characters ("p" and "c" respectively) of the string. You can look at the table of the ASCII characters here: https://www.asciitable.com/
"p" has a Dec value of 112 while "c" has a Dec value of 99, and as you can guest 112 > 99 returns True
Lerena Holloway
9,855 PointsAhhh ok, that makes more sense . Thank so much!!!
Craig Dennis
Treehouse TeacherP comes after C in the alphabet...picture the letters laid out left to right in order.