Bite 33. Transpose a data structure
Login and get codingSometimes you need to restructure a nested data structure. For example you can convert a
dictin alistof (key,value)tuples viadict.items().In this Bite a real world scenario where we wanted to plot some data from a
Counter dict.For plots you typically need 2 lists: X + Y axis or labels + values. So we needed an easy way to transpose data structures.
Complete the
transposefunction to do just that. It has to work for both dicts and lists of (named)tuples. Examples given in the docstring. See also the TESTS tab. Have fun!
257 out of 260 users completed this Bite.
Will you be the 258th person to crack this Bite?
Resolution time: ~47 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.6 on a 1-10 difficulty scale.
» Up for a challenge? 💪