Write a python program that contains a function called word_selection() that takes a list as a parameter and randomly selects one item in the list and prints it. Your program should have the following functionality: 1. Continuously prompt the user to enter a word until the user enters q 2. Store the entered words in a list 3. Making use of the random module, your program should call word_selection() that randomly selects a word from the list and prints it 4. Include the guard for the main function: if __name__ == '__main__': main() Example: Enter a word (or ‘q’ to quit): Wallaby Enter a word (or ‘q’ to quit): Dingo Enter a word (or ‘q’ to quit): Platypus Enter a word (or ‘q’ to quit): q Wallaby
Write a python
1. Continuously prompt the user to enter a word until the user enters q
2. Store the entered words in a list
3. Making use of the random module, your program should call word_selection() that randomly selects a word from the list and prints it
4. Include the guard for the main function:
if __name__ == '__main__':
main()
Example: Enter a word (or ‘q’ to quit): Wallaby Enter a word (or ‘q’ to quit): Dingo Enter a word (or ‘q’ to quit): Platypus Enter a word (or ‘q’ to quit): q Wallaby
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images