asked 146k views
5 votes
Edhesive 4.5 Code Practice

asked
User Kaykun
by
8.2k points

2 Answers

3 votes

Answer:

c = 0

word = input("Enter a word: ")

while word!="STOP":

c = c+1

print("#" + str(c) + ": You entered "+str(word))

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

print("All done. "+str(c)+" words entered.")

answered
User Aarona
by
8.2k points
6 votes

Question: Write a loop that inputs words until the user enters STOP.

Answer:

count = 0

word = input("User Input: ")

while word!="STOP":

count = count+1

print("You entered: "+str(word))

word = input("User Input: ")

print("All done. "+str(count)+" words entered")

Explanation:

This line initializes counter variable count to 0

count = 0

This line prompts user for input

word = input("User Input: ")

The following iteration is executed until user enters STOP

while word!="STOP":

This increments counter variable by 1

count = count+1

This prints the word entered by the user

print("You entered: "+str(word))

This line prompts user for another input

word = input("User Input: ")

This prints the number of input by the user

print("All done. "+str(count)+" words entered")

answered
User Khawar Islam
by
9.4k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.