Question #62842

Write a loop that reads strings from standard input, where the string is either "duck" or "goose". The loop terminates when "goose" is read in. After the loop, your code should print out the number of "duck" strings that were read.
1

Expert's answer

2016-10-21T12:58:08-0400
counter = 0
while True:
    line = input()
    if line == 'duck':
        counter += 1
    elif line == 'goose':
        break
print(counter)
https://www.AssignmentExpert.com

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Jon
11.10.18, 17:12

This works

LATEST TUTORIALS
APPROVED BY CLIENTS