Write a program with a loop that repeatedly reads a string as input, where the string is either "duck" or "goose". The loop terminates when "goose" is entered. After the loop, your code should print out the number of "duck" strings that were read. NOTE: When reading the input, do not display a prompt for the user. Use the input()function with no prompt string. Here is an example: bird = input()

Respuesta :

We use an indefinite while loop to keep the user entering a string. In the loop, we use if-else structure to check the string. If it is "duck", we increment the count by 1. If it is "goose", we stop the loop using a break.

Comments are used to explain each line of the code.

You may see the output in the attachment.

#variable to count the number of duck string entered

count = 0

#create an indefinite while loop. In the loop,

# if the bird is duck, increment the count by 1

# if the bird is goose stop the loop

while True:

   bird = input()

   

   if bird == "duck":

       count += 1

   elif bird == "goose":

       break

#print the count

print("Number of duck(s)", count)

Here is another question related to the loops:

https://brainly.com/question/13642794

Ver imagen frknkrtrn