subject

Write a function that takes in a sequence s and a function fn and returns a dictionary. The values of the dictionary are lists of elements from s. Each element e in a list should be constructed such that fn(e) is the same for all elements in that list. Finally, the key for each value should be fn(e) def group_by(s, fn):
""" >>> group_by([12, 23, 14, 45], lambda p: p // 10)
{1: [12, 14], 2: [23], 4: [45]}
>>> group_by(range(-3, 4), lambda x: x * x)
{0: [0], 1: [-1, 1], 4: [-2, 2], 9: [-3, 3]}
"""
Use Python

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 04:31, tbt81
Type the correct answer in the box. spell all words correctly. the managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, lucywood2024
What is the biggest difference between section breaks and regular page breaks
Answers: 1
image
Computers and Technology, 24.06.2019 10:30, johngayden46
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
image
Computers and Technology, 24.06.2019 12:50, opgbadwolf5
When is it most apprpriate for a development team to change the definition of done
Answers: 1
You know the right answer?
Write a function that takes in a sequence s and a function fn and returns a dictionary. The values o...

Questions in other subjects: