sentence = "Python programming is amazing"
longest_word = max(sentence.split(), key=len)
print(f"Sentence: {sentence}\nLongest Word: {longest_word}")Output:
Sentence: Python programming is amazing
Longest Word: programming
sentence = "Python programming is amazing"
longest_word = max(sentence.split(), key=len)
print(f"Sentence: {sentence}\nLongest Word: {longest_word}")Output:
Sentence: Python programming is amazing
Longest Word: programming