DEV Community

loading...

Discussion on: Whatโ€™s your alternative solution? Challenge #54

Collapse
rafaacioly profile image
Rafael Acioly

Python solution ๐Ÿ

def longest_word(text: str) -> int:
  return max([
    len(word) for word in text.split()
    if not word.isspace()
  ])

content = "Create a function to return the longest word(s) in a sentance."
print(longest_word(content))  # 9