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
Bond [772]
4 years ago
11

Write a function that takes a string like 'one five two' and returns the corresponding integer (in this case, 152). A function j

ust like this would be used in a speech recognition system (e.g. automated phone taxi bookings) to convert a spoken number into an integer value. Here is an attempt that won't work. Your task is to replace the function body with something that works:

Computers and Technology
2 answers:
Lelu [443]4 years ago
4 0

Answer:

see explaination

Explanation:

def words2number(s):

words = s.split()

numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

result = ""

for word in words:

if word in numbers:

result += str(numbers.index(word))

return result

nikitadnepr [17]4 years ago
4 0

Answer:

Check the explanation

Explanation:

def words2number(s):

   words = s.split()

   numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

   result = ""

   for word in words:

       if word in numbers:

           result += str(numbers.index(word))

   return result

# remove below test line before submitting this code.

print(words2number('one five two'))

Kindly check the attached image below for the code output.

You might be interested in
Which of the following does a histogram resemble the most?
jolli1 [7]
C bar graph is closer to a histogram
8 0
4 years ago
What are the best programming languages of 2020 for beginners?<br>​
jek_recluse [69]
Probably skript! Up to you though
8 0
3 years ago
Read 2 more answers
What should you do when asked to take down a detailed message for your manager or supervisor?
katovenus [111]
A makes most sense to me. What if you forget that a voicemail was left? Its better to have them call back later. And if the manager isn't there in an hour have them then leave a voicemail.
8 0
3 years ago
Read 2 more answers
Do you know best way to know WiFi password which you are connected to?​
borishaifa [10]

Answer:

Download a wifi password saver on playstore or appstore

Explanation:

8 0
3 years ago
Read 2 more answers
Which of the following is considered a skill?
faltersainse [42]
I’m not sure what are the following answers but some skills are communication, problem solving, creativity and teamwork
7 0
4 years ago
Other questions:
  • What is a WYSIWIG program
    10·1 answer
  • hardtack was a. a new cone-shaped bullet. c. a type of biscuit. b. a sharp turn made on command. d. a type of body armor.
    6·1 answer
  • Which of the following statements regarding EFT is false? EFT still requires the endorsement of a check EFT allows payment to be
    11·1 answer
  • Cell division is called:
    7·1 answer
  • Read the paragraph.
    12·2 answers
  • To create bold shadows, which lighting choice would work best.
    7·1 answer
  • Write programs for two MSP430 boards to do the following:
    15·1 answer
  • Consider the following code segments that are potential replacements for /* missing code */.
    6·1 answer
  • Describe in detail what each step would look like if you ran into a software error.
    7·1 answer
  • How does lower latency benefit the users connected to a network?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!