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
Mrrafil [7]
4 years ago
14

#Recall in Unit 3 you wrote a function that would count the #number of words in a string using loops. Now that you know #somethi

ng about string methods, though, let's do that again #using a different approach. # #Write a function called "num_words" that accepts a string #as an argument and returns the number of words in the #string. You can assume all words are separated by a space, #and that the string has at least one word. You do not need #to worry about punctuation.
Computers and Technology
1 answer:
LiRa [457]4 years ago
3 0

Answer:

#function to count number of words in a string

def num_words(str1):

# using split() to count words in string

res = len(str1.split())

return res

test_string = input("Enter string:")

# printing original string

print ("The original string is : " + test_string)

# printing result

print("Number of word in entered string:")

print (num_words(test_string))

Explanation:

You might be interested in
WILL GIVE BRAINLIEST! An ________________ is a list of steps needed to answer a problem or finish a task. When the code is execu
Fudgin [204]

Answer:

Event

Explanation:

8 0
3 years ago
Read 2 more answers
The Android operating system was invented by ______.
EleoNora [17]

The Android operating system was invented by <u>google</u> in 2005.

4 0
3 years ago
In 2008, researchers at Princeton University demonstrated techniques to retrieve RAM contents after the computer had been powere
lora16 [44]

It’s called a “Cold Boot” attack
6 0
3 years ago
Which of the following is 1000 of a second​
s344n2d4d5 [400]

Answer:

what I don't understand your question

6 0
4 years ago
97. How many bits is a ki obyte?<br> a. 1000<br> b. 1024<br> c. 8192<br> d. 8124<br> 5
Basile [38]

Answer:

b

1024

is the correct answer

6 0
3 years ago
Read 2 more answers
Other questions:
  • What area contains the command used to customize the print options in microsoft excel?
    9·1 answer
  • Which business document is usually written in block style with the body tedt aligned along its left margin?
    9·1 answer
  • When backing up a database server to LTO tape drives, the following schedule is used. Backups take one hour to complete.
    12·1 answer
  • Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
    6·2 answers
  • Please check my answer! (Java)
    6·1 answer
  • Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to conv
    13·1 answer
  • Create a parent class called Shape with width and height parameters of type double and a function that returns the area of the s
    12·1 answer
  • How to create a trace table
    10·1 answer
  • Write a complete method to create an array of random integers. The method takes in three integer parameters: the array size, the
    9·1 answer
  • Who made computer ? Which year?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!