Python for Everybody - Python Functions

Tell us what’s happening:

Describe your issue in detail here.
Can someone explain to me how the result is ‘w’ for the function
big=max(‘Hello world’)

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.46

Challenge Information:

Python for Everybody - Python Functions

Of all of the characters in the strong “Hello world”, “w” is the latest in the alphabet and therefor has the highest ASCII value.

1 Like

max function in python accepts any type that can be iterated over and returns the largest item. Implicit condition is that iterated elements can be compared.

This includes str type, as individual letters - also with str type - can be compared. For example:

print('a' < 'b')  # False
print('w' > 'H')  # True

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