Concatenate Some Lists X39029


Statement
 

pdf   zip   main.py

Write a function cat_some(d,ks)cat\_some(d, ks) that receives a dictionary dd and a list of possible keys ksks. The keys of dd are integers. The values are lists of integers. The returned result must be the concatenation of the lists corresponding in dd to the keys in ksks, in the same order the corresponding keys appear in ksks. Integers in ksks that do not appear in dd contribute an empty list to the result.

Observation

Please make sure to remove or comment out from the Jutge submission any doctesting code you might have in your source code.

Sample session
>>> cat_some({ 55: [0, 1, 4], 30: [-7, 7], 0: [0] }, [30, 55])
[-7, 7, 0, 1, 4]
>>> cat_some({ 55: [0, 1, 4], 30: [-7, 7], 0: [0], 2345: [ 23, 4, 56 ]  }, [ 0, 1, 2, 55, 0 ])
[0, 0, 1, 4, 0]
>>> cat_some({ 55: [0, 1, 4], 30: [0] }, [ 66, 55 ]) + cat_some({ 55: [0, 1, 4], 30: [0] }, [ 66, 55 ])
[0, 1, 4, 0, 1, 4]
>>> cat_some({ }, [ ])
[]
Information
Author
Language
English
Official solutions
Python
User solutions
Python