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
Which invention replaced vacuum tubes in computers?
dlinn [17]

Answer:

Transistors

Explanation:

6 0
2 years ago
Match the vocabulary to the appropriate definition.
Allisa [31]

Answer:

Pulling related code together in objects is Arrays

Helps programmers when they revisit code or are new to code-- Documentation

Explanation:

This is all I know

3 0
2 years ago
To erase a character to the right of the insertion point, press the ____ key(s).
jeka94
<span><span>CTRL+HOME then delete, backspace, end.</span></span>
8 0
3 years ago
A keyboard shortcut is a key or combination of keys that you press to access a feature or perform a command. ___________________
andrey2020 [161]
I believe that this is true.
Ctrl+F
Ctrl+C
Ctrl+V
These are all keyboard shortcuts.

8 0
3 years ago
What is the best computer for college?
scoundrel [369]
Acer Chromebook is a great computer made by Google!

4 0
3 years ago
Other questions:
  • While working alone at their respective constant rates, computer X processes 240 files in 4 hours and computer Y processes 240 f
    11·1 answer
  • )1-bit sign, 8-bit exponent, 23-bit fraction and a bias of127 is used for ___________ Binary Floating PointRepresentation
    11·1 answer
  • Julie bought a house for $315,000 and has a $285,000 mortgage. she claims she has $315,000 in equity. is she correct? if not, ho
    12·2 answers
  • Declare a character variable letterStart. Write a statement to read a letter from the user into letterStart, followed by stateme
    12·1 answer
  • The______for our newest game keeps changing as we develop our concept and refine our goals.
    11·2 answers
  • Select the correct answer.
    15·1 answer
  • Copyright applies to work at the time it was produced, written, and developed. True or False?
    10·2 answers
  • 4. UPS stands for Uninterrupted Power Supply . (Yes /no
    11·1 answer
  • Who is the monst important person and why
    11·1 answer
  • What is System Testing
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!