Crazy python behaviour

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2009-10-10T12:45:38Z Indexed on 2010/05/13 17:04 UTC
Read the original article Hit count: 421

Filed under:
|

I have a little piece of python code in the server script for my website which looks a little bit like this:

console.append([str(x) for x in data])
console.append(str(max(data)))

quite simple, you might think, however the result it's outputting is this:

['3', '12', '3']
3

for some reason python thinks 3 is the max of [3,12,3]!

So am I doing something wrong? Or this is misbehaviour on the part of python?

© Stack Overflow or respective owner

Related posts about python

Related posts about max