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 Types and Branching Comparing values

Dejuan Castro
Dejuan Castro
198 Points

P > C ? Really.

The question is what would the result from this be. python > chocolate . python is greater than chocolate should result as false but it says it's true. What am I getting wrong?

Luis Munguia Salas
Luis Munguia Salas
14,797 Points

you can get the ASCII value of a character with

print(ord('p'))
>> 112
print(ord('c'))
>> 99

check the website below for more values >>>>>>>>

https://www.w3resource.com/python-exercises/python-basic-exercise-86.php

1 Answer

Steven Parker
Steven Parker
231,186 Points

When using inequality tests on strings, you're actually comparing dictionary order. Which ever one comes later in the dictionary is considered to be "greater".

So yes, "P > C" (P comes after C).