Skip to content

Instantly share code, notes, and snippets.

@aleksbelic
Created October 14, 2020 23:16
Show Gist options
  • Save aleksbelic/b4a40df972ed9084d77fe89077184703 to your computer and use it in GitHub Desktop.
Save aleksbelic/b4a40df972ed9084d77fe89077184703 to your computer and use it in GitHub Desktop.
Function prints the longest word/words in a given list.
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