Question: import random def piglet ( ) : Plays a game of Piglet. print ( Welcome to Piglet! ) total _ score
import random
def piglet:
Plays a game of Piglet."""
printWelcome to Piglet!"
totalscore
while True:
roll random.randint # Roll the die
printfYou rolled a roll
if roll : # Game ends if a is rolled
totalscore
break
totalscore roll # Add the roll to the total score
# Continue prompting for input until a valid response is given
while True:
rollagain inputRoll again? yn: lower
if rollagain in yn:
break
printInvalid input. Please enter y or n
if rollagain y:
break
printfYou got totalscore points."
if namemain:
piglet
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
