Here , we are going to write python program to print the words starting with particular alphabet in a user entered string . Sometimes, we require to get the words that start with the specific letter. Let’s discuss this problem in Python.
s = input("Enter any sentences : ") a = input("Enter any alphabet to find :") found = False words = s.split() for word in words: if word.startswith(a): print(word) found = True if (found == False): print("No word starting with user entered alphabet")
Enter any sentences : hello athang whats up
Enter any alphabet to find :h
Enter any sentences : today is holiday ,we can take rest today
Enter any alphabet to find :t