Max and min in strings


#1

how does the max and min functions work in the strings?

name = 'hello'
print (max(name))

it gives output as 'o'

and

print (min(name))

gives the output as 'e'

can some one explain this in detail?


#2

(max(name))This method returns the max alphabetical character from the string.

(min(name))This method returns the min alphabetical character from the string.

name = 'hello'
print (max(name))

it gives output as 'o'

because o comes after e h l l(remember alphabet A B C D ...............)

same for (min(name))
gives the output as 'e'

because e comes before h l l o


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.