Created
October 14, 2020 23:16
-
-
Save aleksbelic/b4a40df972ed9084d77fe89077184703 to your computer and use it in GitHub Desktop.
Function prints the longest word/words in a given list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def longest_words(words): | |
max_len = max(len(word) for word in words) | |
for word in words: | |
if len(word) == max_len: | |
print(word) | |
longest_words(["once", "upon", "a", "time"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment