Find out for each word in a sentence whether it has a given prefix.
Nothing fancy: a case-sensitive solution on a space-split text will do (there is no need to switch the case or deal with punctuation marks).
Print all the matched words preserving the order.
Input: a prefix and a sentence on separate lines.
Output: words with the given prefix on separate lines.
Checking whether a string starts with a specific substring is one of the most common tasks, which is why Python has a string method called
str.startswith()
. It is equally important to know about it and to be able to implement this algorithm yourself. You are supposed to write your own function here. Seize a chance to test your strength!