Question: 1. roll again? In the file named pig.py, write a function named rollAgain that asks a user to enter either yes or no, and returns




1. roll again? In the file named pig.py, write a function named rollAgain that asks a user to enter either "yes" or "no", and returns the string entered by the user. If the user doesn't enter "yes" or "no", your function should print an error message, and prompt the user to try again. The function should only return when the user enters a valid string value. The rollAgain function does not take any input values (it has no parameters), but it should return a string value. Its function definition will look like: def rollAgain(): Your main function should make a call to the rollAgain function and print out the value returned. Here are some examples of how the program should work up to this point: $ python3 pig.py Do you want to roll again? yes rollAgain returned yes $ python3 pig.py Do you want to roll again? Yes Whoops! Yes isn't a valid choice. Try again. Do you want to roll again? why didn't that work Whoops! why didn't that work isn't a valid choice. Try again. Do you want to roll again? nope Whoops! nope isn't a valid choice. Try again. Do you want to roll again? no rollAgain returned no Remember that python strings can be compared with relational operators like == or
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
