192k views
0 votes
4.2 code need help plz someone 15 points if u help

4.2 code need help plz someone 15 points if u help-example-1

1 Answer

6 votes

def func():

total = 0

while True:

pet = input("What pet do you have? ")

if pet == "rock":

return

total += 1

print("You have a {} with a total of {} pet(s)".format(pet, total))

func()

We wrapped our code in a function so that whenever the user enters rock, we can simply return and exit the function. If you have any other questions, I'll do my best to answer them.

User David Alber
by
8.5k points

No related questions found