1
t=('ali','rahul','ram')

In the above code, when I run the max function,

print(max(t))

this is the output I get : ram

Why do I get Ram and not Ali?

lenik
  • 23,228
  • 4
  • 34
  • 43

1 Answers1

3

max() will return the largest element, either by comparing numbers or comparing strings lexicographically (the same way words are ordered in a dictonary -- the book one, not the python dict()):

>>> max((1,2,3))
3
>>> max(('b','a','c'))
'c'
>>> 
lenik
  • 23,228
  • 4
  • 34
  • 43