146k views
5 votes
Edhesive 4.5 Code Practice

User Kaykun
by
5.7k 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.")

User Aarona
by
5.1k 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")

User Khawar Islam
by
6.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.