Write a loop that inputs words until the user enters STOP. After each input, the program should number each entry and print in this format:
#1: You entered _____
When STOP is entered, the total number of words entered should be printed in this format:
All done. __ words entered.
Sample Run
Please enter the next word: cat
#1: You entered cat
Please enter the next word: iguana
#2: You entered iguana
Please enter the next word: zebra
#3: You entered zebra
Please enter the next word: dolphin
#4: You entered dolphin
Please enter the next word: STOP
All done. 4 words entered.
in python plz
Answers
Answered by
3
Refer to this image
Hope this helps
Answered by
0
Program is given below.
Explanation:
Program:
def function():
i = 0
while True:
give_a_word=input ( "Please enter the next word: ")
if give_a_word == "STOP":
print("All done. {} words entered.".format(i))
return
i + = 1
print("#{}: Your entered {}".format(i, give_a_word))
function()
Refer the attached image for the output.
Attachments:
Similar questions
Math,
2 months ago
Geography,
2 months ago
Computer Science,
6 months ago
Math,
10 months ago
Science,
10 months ago