Question: Complete the get_valid_word() function that takes no parameters. The get_valid_word() function prompts the user to enter a word. The word must start with the letter
Complete the get_valid_word() function that takes no parameters. The get_valid_word() function prompts the user to enter a word. The word must start with the letter "d" and end with the letter "r", both lowercase. While the user does not enter a valid word, the function informs them of their error and prompts them again. When the user does enter a valid word, the function returns it.
For example:
| Test | Input | Result |
|---|---|---|
print("Your word is", get_valid_word()) | Damir dream mirror deer | Please enter a word beginning with the letter 'd' and ending with the letter 'r': Damir Your word is invalid! Try again Please enter a word beginning with the letter 'd' and ending with the letter 'r': dream Your word is invalid! Try again Please enter a word beginning with the letter 'd' and ending with the letter 'r': mirror Your word is invalid! Try again Please enter a word beginning with the letter 'd' and ending with the letter 'r': deer Your word is deer |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
