Back to questions
JuniorTheoryCommon
What does the program print?
words = ["sun", "ox", "planet"]
print(any(len(w) > 5 for w in words), min(words, key=len), max(words))True ox sun
- Expecting
planetfrommax(words): withoutkey=strings compare letter by letter, not by length;scomes afteroandpin the alphabet, so"sun"is the largest. - Expecting
min(words, key=len)to return2:keyonly decides how items are compared;minreturns the item itself,"ox".
- How would you get the longest word with
max? - What does
all(len(w) > 2 for w in words)print?