[Tutor] comparing strings

Corey Richardson kb1pkl at aim.com
Thu Feb 24 04:29:58 CET 2011


On 02/23/2011 10:22 PM, Edward Martinez wrote:
> Hi,
> 
> I'm new to the list and programming.
> i have a question, why when i evaluate strings ie 'a' > '3' it reports 
> true,  how does python come up with  that?

Welcome! As far as I know, it compares the value of the ord()'s.

>>>ord('a')
97
>>>ord('3')
51

This is their number in the ASCII system. You can also do this:

>>>chr(97)
'a'
>>>chr(51)
'3'

-- 
Corey Richardson


More information about the Tutor mailing list