1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Taya2010 [7]
3 years ago
13

Count the number of words in the string. A word is one or more non-blank characters separated by one or more blanks. My suggesti

on is to use a flag (a boolean variable) to indicate whether or not you are in a word. Then you know you have found a word when the flag indicates that you are in a word and the next character is a blank. Think about how you will know when you have found the end of a word, and what you should do with your flag at that point.
Computers and Technology
1 answer:
NikAS [45]3 years ago
7 0

Answer:

myString = input("Please enter a string")

wordList = myString.split()

numofWords = len(wordList)

print('The number of words in {} is {}'.format(myString, numofWords))

Explanation:

Since the suggestion to use a boolean variable flag is not compulsory, I have implemented it in another way.

Using python programming language, the input function is used to prompt the user to enter a string which is saved in a variable myString.

The string entered is converted into a list of all the words by spliting at the blank spaces and saved in the variable wordList

Next we count the number of words by obtaining the len of the list and output to the user

You might be interested in
Why is it more secure to require a user to press ctrl+alt+delete to log on rather than displaying the windows welcome screen?
Levart [38]
Let's say for example you have a toddler, or a pet. Let's say a cat. If the ctrl+alt+delete wasn't there. It would go straight to entering the password. Now let's say your child or pet likes to press the keys for a while. If they manage to press enter and enter the incorrect password. Eventually it will lock up your computer.
5 0
3 years ago
knowledge contributes vitally to the development of __________ memory, or recollections of personally experienced events that oc
Anettt [7]

Answer:

Episodic

Explanation:

Episodic memory are memory that enables a person to remember most important event that happen to them, which are unique to them and are tied to a specific time and place.

It can be the memory of every day events or experiences that occured to the person at a particular time and date.

Example:

Episodic memory is when an individual remember his /her date of birth or specific events and experiences.

Therefore Knowledge contributes vitally to the development of EPISODIC memory, or recollections of personally experienced events that occurred at a specific time and place.

5 0
3 years ago
Plz plz plz subsribe to my channel, CookieFunTime
Anastaziya [24]

Answer:

Sure

Explanation:

5 0
2 years ago
Hello pls answer<br><br><br>what is the use of loop in java​
xxMikexx [17]
The use of loop in java is to run a block of code for a certain number of times.
7 0
3 years ago
How many possible keys does the playfair cipher have? an approximate power of 2
Lorico [155]
I don't know but I am guessing 666 or 777 or 888.
7 0
3 years ago
Other questions:
  • What are the desirable qualities of a Product Vision?
    11·1 answer
  • A user saves a password on a website the user logs into from a desktop. Under which circumstances will the password be saved on
    14·1 answer
  • The system restore utility can be started from command line using what executable?
    11·1 answer
  • Count input length without spaces, periods, or commas Given a line of text as input, output the number of characters excluding s
    8·2 answers
  • Which of the following is a technique used by hackers to identify unsecured wireless network locations to other hackers?A. Blues
    10·1 answer
  • Why did Herman Hollerith invent the Tabulating Machine?
    10·1 answer
  • If the algorithm does not have instructions for unanticipated results, the computer program will
    15·1 answer
  • create a function that draws a certain number of spaces, followed by a certain number of stars, followed by a newline.
    6·1 answer
  • Write a Python program (rainfall.py) to collect data and calculate the average rainfall over a period of years. The program shou
    11·1 answer
  • If you do not clean your hardware on a regular basis, which of these is most likely to be a problem?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!