147k views
4 votes
50 POINTS NEED HELP ASAP!

(PYTHON)

Write a loop that continually asks the user what pets the user has until the user enters stop, in which case the loop ends. It should acknowledge the user in the following format. For the first pet, it should say You have one cat. Total # of Pets: 1 if they enter cat, and so on.

Sample Run
What pet do you have? lemur
What pet do you have? parrot
What pet do you have? cat
What pet do you have? stop
Sample Output
What pet do you have? lemur
You have one lemur. Total # of Pets: 1
What pet do you have? parrot
You have one parrot. Total # of Pets: 2
What pet do you have? cat
You have one cat. Total # of Pets: 3
What pet do you have? stop

1 Answer

3 votes

Answer:

def main():

animals = []

while True:

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

if animal == "stop":

break

else:

animals.append(animal)

for i in range(len(animals)):

print(f'You have one {animals[i]}. Total # of Pets: {i + 1}')

Step-by-step explanation:

User ChromeHearts
by
3.2k points