DEV Community

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