[Tutor] comparing strings

Edward Martinez edwardcru1 at aol.com
Thu Feb 24 04:54:25 CET 2011


On 02/23/11 19:29, Corey Richardson wrote:
> 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'
>
    Hi,
   Thank you!. I better read on   ASCII and unicode and try a few using  
char() and ord().

    Regards,
    Edward


More information about the Tutor mailing list