56,405 views
42 votes
42 votes
Write a loop that inputs words until the user enters DONE. After each input, the program should number each entry and print in this format:

#1: You entered _____
When DONE is entered, the total number of words entered should be printed in this format:

A total of __ words were entered.
Sample Run
Please enter the next word: cat
#1: You entered the word cat
Please enter the next word: iguana
#2: You entered the word iguana
Please enter the next word: zebra
#3: You entered the word zebra
Please enter the next word: dolphin
#4: You entered the word dolphin
Please enter the next word: DONE
A total of 4 words were entered.

User Awiseman
by
3.0k points

1 Answer

12 votes
12 votes

Answer:

def main():

word = input("Please enter the next word: ")

count = 0

while word != "DONE":

count += 1

print("#{}: You entered the word {}".format(count, word))

word = input("Please enter the next word: ")

print("A total of {} words were entered.".format(count))

main()

User Xavier John
by
2.6k points