Respuesta :
Following are the Python program to input string value and count its value.
Program Explanation:
- Defining a method words.
- Inside a method, an integer variable "c" and string variable "word" is declared, and a while loop is defined.
- Inside the loop, we input the string value and define a conditional statement is declared that checks word value not equal to STOP.
- In this, it counts total input values and prints the value with the message.
- At the last, we call the method.
Program:
def words():#defining a method words
c=0#defining an integer variable c
word="empty"#defining a string variable
while (word != "STOP"):#defining a loop that runs when word value is not equal to STOP
word = input("Please enter the next word: ")#using word that inputs value
if word != "STOP":#defining if block that checks word value not equal to STOP
c+=1#incrementing c value
print("#"+str(c)+": You entered "+ word)#print input value with message
print( "All done "+ str(c) +" words entered")#print total count of input value
words()#calling method
Output:
Please find the attached file
Learn more:
brainly.com/question/18750495
