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
When might be the best time to start saving for retirement?
Nata [24]

Answer

At the earliest possible date.

Explanation

Retirement is the act of leaving your job and stopping working, usually because you are old: Your retirement benefit is based on your highest years of earnings and savings and your age when you start receiving benefits. consistently saving a little money for retirement at the earliest possible date.is much better than saving a lot more money when you are in your fifties.

4 0
3 years ago
Read 2 more answers
How to buy free big money computers that earn free money everydays?
Novay_Z [31]
That would be great if it was possible
8 0
2 years ago
Pictures that you can click on to tell your computer what to do.
Tom [10]
What do you mean ? I’m confused..
6 0
3 years ago
Read 2 more answers
Convert<br> 0.625 to binary
Anastaziya [24]

\huge{ \rm{Question:}}

Convert

0.625 to binary

\huge{ \rm{Answer:}}

Translate 0.625 into a fraction. We all know that 0.5 is ½. We know that the remainder, 0.125, is ⅛. Add them together, and you get ½ + ⅛ = ⅝.

Now, in binary, the positions to the right of the point are , which is ½, ¼, and ⅛ respectively.

⅝ is 5 × ⅛. 5 in binary is 101. So, ⅝ is

= 0.101

8 0
2 years ago
All of the following are ways to save money on transportation except :
Lisa [10]
The options listed are not related to the question. and if they were related in any sense then I would say the cheapest thing on the list is a phone card so I guess you can buy that and save the most for your travel as you can use phone cards anywhere as they have 1800 numbers which are free from any public phone. 
7 0
3 years ago
Other questions:
  • Remember that the function "main" takes optional parameters, these being common:
    10·1 answer
  • What is credibility in the often-used framework of quality criteria?
    9·1 answer
  • List and describe the tools for all the main stages of app/application development.
    11·1 answer
  • Write a C++ program to find if a given array of integers is sorted in a descending order. The program should print "SORTED" if t
    14·1 answer
  • What does remedy mean
    7·2 answers
  • discuss the benefits of normalization, and do you think we should normalize our designs to higher levels than 3NF? Why or why no
    9·1 answer
  • Can someone start me off with a short 2 or 3 paragraphs about the pros and cons of Microsoft Word, and if you can recommend a si
    12·1 answer
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
  • Charles was supposed to present his PowerPoint slides to his classmates in a classroom, but now he has to present in the auditor
    12·2 answers
  • Write a program to find the sum of first 10 even numbers in qbasic​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!