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
Ghella [55]
3 years ago
14

: Write a function "def countWords(string)" that returns a count of all words in an input string represented by the variable 'st

ring'.
Computers and Technology
1 answer:
Zina [86]3 years ago
3 0
We can define a word as a group of characters without a space between them. To find the words of the input string , w can use split(delimiter) which returns a list of strings which had the defined delimiter between them in the input string.

def countWords(string):
words = string.split(" ")
count = len(words)
return count

Here we set the delimiter as the space character, and returned the length of the words list. I split each step into its own line for readability, however the function could be one line:

return len(string.split())

Here, no delimiter is specified. If one isn't given, it will default to split at any whitespace, including space.

You might be interested in
You are a disgruntled employee with a master’s degree in computer sciences who was recently laid off from a major technology com
WARRIOR [948]

Answer:

If you know what you're doing, I'd suggest hacking into the company's website...

Explanation:

3 0
3 years ago
In what year was the 1st zelda game released
cluponka [151]
Bro it was realesd in 1997
5 0
3 years ago
Read 2 more answers
Tạo biến
rewona [7]

Answer:

WHERE ARE YOU FROM

Explanation:

TRANSLATE IT TO ENGLISH

5 0
3 years ago
The factors of power of device
LUCKY_DIMON [66]

Answer:

tfopod

Explanation:

5 0
2 years ago
If Tamya makes $1000.00 gross monthly income and her total payroll deductions are $294.00, what is her net income?
Maru [420]

Answer:

$751

Explanation:

From the question we have the following information;

Gross income = $1000.00

Deductions =   $294.00

Now we know that;

Net income = Gross income - Deductions

Therefore;

Net income = $1000.00 -  $294.00

Net income = $751

7 0
3 years ago
Other questions:
  • A deleted file or folder is not permanently deleted from a computer until which event occurs? The computer is restarted. The Rec
    13·2 answers
  • What is PHP language
    12·1 answer
  • Which of the following is the best definition of being a “digital citizen”?
    6·2 answers
  • print out the last even number from an array of integers, if there is no even number, then print out a sentence indicating so.
    5·1 answer
  • Can you help me, please
    10·1 answer
  • The space where text and content is entered and positioned for onscreen reading or printing
    8·1 answer
  • What is the largest place value in a 12 bit binary number?
    10·1 answer
  • Would my phone still work if I snapped it in half?
    8·2 answers
  • Computers that are joined together are called networks true or false
    10·1 answer
  • Fun with Characters
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!