문장을 입력받아 가장 긴 단어를 찾는 예제를 작성해 보았다.
샘플코드
def find_longest_word(sentence):
words = sentence.split()
return max(words, key=len)
# Example usage
text = "It only takes about 20 minutes to find out about your accurate English level"
print("Longest word:", find_longest_word(text))
결과
Longest word: accurate
반응형