Python
# Program to find the shortest word in a sentence
sentence = input("Enter a sentence: ")
words = sentence.split()
if not words:
print("No words found.")
else:
shortest = min(words, key=len)
print("Shortest word:", shortest)Output
Enter a sentence: this is a test Shortest word: a
We use min(words, key=len) to get the shortest word by length.