[Tutor] string rules for 'number'
Joel Goldstick
joel.goldstick at gmail.com
Sun Oct 7 19:56:38 CEST 2012
On Sun, Oct 7, 2012 at 1:46 PM, Arnej Duranovic <arnejd5 at gmail.com> wrote:
> When I type this in the python idle shell ( version 3...) :
> '0' <= '10' <= '9'
> The interpreter evaluates this as true, WHY? 10 is greater than 0 but not 9
> Notice I am not using the actual numbers, they are strings...I thought that
> numbers being string were ordered by their numerical value but obviously
> they are
> not? Can anyone explain this to me and explain how strings with numbers in
> them are ordered?
>
> Thx in advance.
>
because '0' is less than '1', and '1' is less than '9'
The comparison is done on a character by character basis
--
Joel Goldstick
More information about the Tutor
mailing list