subject

Your task is to implement a function replace_once(t, d), that takes a text t and a replacement dictionary d, and returns the result of replacing words according to the dictionary: if a word appears as a key, replace it with the dictionary value, and if a word does not appear in the dictionary, leave it alone. Given a list of words, you can concatenate them together with spaces in between as follows:
word_list = "I love eating bananas".split()
print("Word list:", word_list)
back_together = " ".join(word_list)
print("Back together:", back_together)
# You can also join them in other ways, btw. Just DON'T do it for this homework.
print("You can also put commas:", ", ".join(word_list))

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:00, ladyree8721
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
image
Computers and Technology, 23.06.2019 02:00, eila3601
As with any small island country, cuba has fewer natural resources than countries such as brazil. this affects their economy in that cuba a) exports only manufactured products. b) exports more products than it imports.. c) must import more products than it exports. d) has imposed trade barriers against the united states.
Answers: 3
image
Computers and Technology, 23.06.2019 10:30, badpotterchris
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
image
Computers and Technology, 23.06.2019 12:50, tommy4260
Which syntax error in programming is unlikely to be highlighted by a compiler or an interpreter? a variable name misspelling a missing space a comma in place of a period a missing closing quotation mark
Answers: 1
You know the right answer?
Your task is to implement a function replace_once(t, d), that takes a text t and a replacement dicti...

Questions in other subjects:

Konu
Mathematics, 23.05.2020 01:58
Konu
Mathematics, 23.05.2020 01:58
Konu
Mathematics, 23.05.2020 01:58