views:

56

answers:

1

How can I take a dictionary and split it into two lists, one of keys, one of values. For example take:

{'name': 'Han Solo', 'firstname': 'Han', 'lastname': 'Solo', 'age': 37, 'score': 100, 'yrclass': 10}

and split it into:

['name', 'firstname', 'lastname', 'age', 'score', 'yrclass']
# and
['Han Solo', 'Han', 'Solo', 36, 100, 10]

Any ideas guys?

+9  A: 

Not that hard, try help(dict) in a console for more info :)

keys = dictionary.keys()
values = dictionary.values()
WoLpH
Cool. I really should have worked this one out :)
Fergus Barker