Advertisement
here2share

# compr_dict2values4list.py

Jan 31st, 2025
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # compr_dict2values4list.py
  2.  
  3. nested_dict = {
  4.     'Ax': {'a': 1, 'b': 2},
  5.     'Bx': {'c': 3, 'd': 4},
  6.     'Cx': {'e': 5, 'f': 6}
  7. }
  8.  
  9. # Convert nested dict to desired format
  10. converted_dict = {k: list(v.values()) for k, v in nested_dict.items()}
  11.  
  12. print(converted_dict)
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement