Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a sorted list of the values by keys sorted in alpabetical order (i.e [5,4,1,3,2])?
Answer

[v for (k,v) in sorted(d.items())]

^^^ also accurate is: [d[x] for x in sorted(d.keys())]


Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a sorted list of the values by keys sorted in alpabetical order (i.e [5,4,1,3,2])?
Answer
?

Question
In python, you have dictionary, d = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5}, how do you return a sorted list of the values by keys sorted in alpabetical order (i.e [5,4,1,3,2])?
Answer

[v for (k,v) in sorted(d.items())]

^^^ also accurate is: [d[x] for x in sorted(d.keys())]

If you want to change selection, open document below and click on "Move attachment"

pdf

owner: kkhosravi - (no access) - PYTHON_DATA_STRUCTURES_AND_ALGORITHMS.pdf, p56

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.