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
What is unique about the TODAY and NOW functions?
Degger [83]

Answer:

The formula does not require arguments.

Explanation:

One of the programs or software that runs on a computer is Microsoft Office programs. One of these programs is called Microsoft Excel. It is a spreadsheet program where calculations can be made, graphs, diagrams can be plotted and drawn as well.

In other to utilize Microsoft Excel properly, we make use of what we call FUNCTIONS. Functions in Microsoft Excel are defined as formulas, that have already been prepared or created before hand in the Microsoft Excel program so that we can be able to used Microsoft Excel properly and efficiently. Functions may or may not require ARGUMENTS to carry out necessary calculations.

An ARGUMENT is a number or variable that functions require to carry out or do their calculations.

Examples of the functions found in Microsoft Excel are the TODAY and NOW functions. These two functions are used in spreadsheets on Microsoft Excel with regards to Date and Time.

TODAY function is used to give us or update the current or present date while the NOW function gives us or updated the current date and time.

The uniqueness or similarities between the TODAY and NOW functions is that their formula do not require arguments.

3 0
2 years ago
Read 2 more answers
Microsoft acknowledged that if you type a res:// url (a microsoft-devised type of url) which is longer than ____ characters in i
cluponka [151]
Which is longer than 20 characters
5 0
3 years ago
When was microsoft word for windows invented?
Dahasolnce [82]
1981 fue inventado por Bill gates y paul allen
4 0
2 years ago
1. According to the Department of Commerce, _________ percent of single moms in the US qualified as poor.​
Allisa [31]

Answer:

. According to the Department of Commerce, 34.0% percent of single moms in the US qualified as poor.​

Explanation:

8 0
3 years ago
Is LTE faster than 4G?
ser-zykov [4K]
I thought there is a phone.4GLTE maybe internet
3 0
3 years ago
Other questions:
  • Disconnecting or making the equipment safe involves the removal of all energy sources and is known as _____________. A) Isolatio
    8·2 answers
  • If your network subnet mask is /16, what is the maximum number of host ids available for this network?
    15·1 answer
  • The file type ____ identifies a word 2013 document.
    11·1 answer
  • lance measured 0.485 liter of water. Angel measured 0.5 liter of water. lance said, "My beaker has more water than yours because
    6·2 answers
  • Why do TV shows/Movies from the 90's and early 2000s look so much different compared to today?
    7·1 answer
  • What is the difference between a try block and a try statement? Group of answer choices There is no difference; the terms can be
    6·1 answer
  • Which one is not the part of motherboard ?<br>O Registers<br>O<br>Bus<br>O<br>Port<br>O<br>none​
    14·1 answer
  • A buffer storage that improve computer performance by reducing access time is​
    13·1 answer
  • Why is a computer called"a computer"?​
    12·2 answers
  • How to use emojis on chromebook without on-screen keyboard
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!