subject
Computers and Technology, 09.09.2019 19:10 aris35

#now let's make things a little more challenging.
#
#last exercise, you wrote a function called word_count that
#counted the number of words in a string essentially by
#counting the spaces. however, if there were multiple spaces
#in a row, it would incorrectly add additional words. for
#example, it would have counted the string "hi david" as
#4 words instead of 2 because there are two additional
#spaces.
#
#revise your word_count method so that if it encounters
#multiple consecutive spaces, it does *not* count an
#additional word. for example, these three strings should
#all be counted as having two words:
#
# "hi david"
# "hi david"
# "hi david"
#
#other than ignoring consecutive spaces, the directions are
#the same: write a function called word_count that returns an
#integer representing the number of words in the string, or
#return "not a string" if the input isn't a string. you may
#assume that if the input is a string, it starts with a
#letter word instead of a space.
#write your function here!
#below are some lines of code that will test your function.
#you can change the value of the variable(s) to test your
#function with different inputs.
#
#if your function works correctly, this will originally
#print:
#word count: 4
#word count: 2
#word count: not a string
#word count: not a string
#word count: not a string
print("word count: ", word_count("four words are here! "))
print("word count: ", word_count("hi david"))
print("word count: ", word_count(5))
print("word count: ", word_count(5.1))
print("word count: ", word_count(true))

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:30
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
You know the right answer?
#now let's make things a little more challenging.
#
#last exercise, you wrote a functi...
Questions
question
Mathematics, 26.01.2021 01:00
question
Mathematics, 26.01.2021 01:00
question
Mathematics, 26.01.2021 01:00
question
English, 26.01.2021 01:00
Questions on the website: 13722367