I have a dictionary d = {1:-0.3246, 2:-0.9185, 3:-3985, ...}.
How do I extract all of the values of d into a list l?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you only need the dictionary keys
1,2, and3use:your_dict.keys().If you only need the dictionary values
-0.3246,-0.9185, and-3985use:your_dict.values().If you want both keys and values use:
your_dict.items()which returns a list of tuples[(key1, value1), (key2, value2), ...].