0

I have a question about Python:

tuple1 = (123, 'xyz', 'zara', 'abc', 9681)

print "Max value element : ", max(tuple1)

Why the output is 'zara' not 9681?

1 Answers1

0

Because it is order by ascii table. 'z' is 122 and '1' is 49. For this reason, it will return 'zara'

Formula-G
  • 29
  • 1
  • 6
  • 1
    It's got nothing to do with the ascii collating sequence. Try `max((123, ' ', 456))`: the result is `' '` even though the space is ascii 32, lower than all other printable characters. – BoarGules Jun 21 '17 at 07:32