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 trialRoutine Poutine
26,050 PointsHow is "python" > "chocolate" alphabetically? I am thinking "p" comes after "c," so I do not understand this.
How does alphabetical order put python before chocolate? I forgot this part of the material.
2 Answers
Steven Parker
231,072 PointsYou're right, "p" comes after "c", and that's why "python" > "chocolate".
Think about how it would be with numbers — 8 comes after 3, so 8 > 3.
Make sense now?
Routine Poutine
26,050 PointsIf ord("a") is 97, what comes before the alphabet? Is 96 a symbol?
Chris Freeman
Treehouse Moderator 68,427 PointsIt appears to be grave accent
>>> ord('a')
97
>>> chr(97)
‘a’
>>> chr(96)
‘`’
>>>
Chris Freeman
Treehouse Moderator 68,427 PointsThe numbers come from the ASCII tables
Chris Freeman
Treehouse Moderator 68,427 PointsChris Freeman
Treehouse Moderator 68,427 PointsTo see it in code:
Steven Parker
231,072 PointsSteven Parker
231,072 Pointsor just... and:Chris Freeman
Treehouse Moderator 68,427 PointsChris Freeman
Treehouse Moderator 68,427 PointsAlso, true. The point of the
ord()
is to show how python determines the actual ordering. Python uses theord()
values underneath under the hood.Steven Parker
231,072 PointsSteven Parker
231,072 PointsGood illustration .. I guess I should have said "and" instead of "or".
Routine Poutine
26,050 PointsRoutine Poutine
26,050 PointsThanks so much. I completely overlooked that logic.