Re: math functions with non numeric args

Discussion in 'Python' started by Ian Kelly, Jun 30, 2013.

  1. Ian Kelly

    Ian Kelly Guest

    On Sun, Jun 30, 2013 at 12:46 PM, Andrew Z <> wrote:
    > Hello,
    >
    > print max(-10, 10)
    > 10
    > print max('-10', 10)
    > -10
    >
    > My guess max converts string to number bye decoding each of the characters
    > to it's ASCII equivalent?


    No, it leaves the types as they are but simply considers strings to be
    "greater than" numbers. As another poster stated, this is fixed in
    Python 3, where strings and numbers are considered inorderable.
    Ian Kelly, Jun 30, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    491
    David Eppstein
    Sep 17, 2003
  2. VK
    Replies:
    15
    Views:
    1,160
    Dr J R Stockton
    May 2, 2010
  3. Andrew Z
    Replies:
    1
    Views:
    92
    Irmen de Jong
    Jun 30, 2013
  4. Andrew Berg
    Replies:
    0
    Views:
    103
    Andrew Berg
    Jun 30, 2013
  5. MRAB
    Replies:
    0
    Views:
    100
Loading...

Share This Page