+ 3
Why does the Max of my tuples return yellow?
Trying to understand how the different functions and methods work within python. So I wanted to experiment and see what happens with the below code. However, I am really struggling to figure out why ''' print(max(colours)) ''' equates to yellow. input >colours = ("black", "red", "green","yellow","purple", "orange") >print(colours[0]) >print(max(colours)) Output > black > yellow
3 Answers
+ 10
the comparison is done lexicographically for strings
so yellow (which starts with 'y' has the highest value)
+ 3
đ
0
thank you so much for the swift reply, and of course!!!