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()
i = True
j = 0
while i:
n = input('')
if n == 'goose':
break
elif n != 'duck':
print('only goose or duck is allowed')
break
else:
j = j + 1
print(j)
duck
duck
goose
2
Comments
Leave a comment