I am trying to turn a nested list like this: (Example list)
[['A','1','2','3'], ['B','4','5','6'],...]
To a dictionary that looks like this
{'A':'1','2','3','B': '4','5','6'}
Can someone please help me?
I am trying to turn a nested list like this: (Example list)
[['A','1','2','3'], ['B','4','5','6'],...]
To a dictionary that looks like this
{'A':'1','2','3','B': '4','5','6'}
Can someone please help me?
You can use dictionary comprehension:
lst = [['A','1','2','3'], ['B','4','5','6']]
{e[0]: e[1:] for e in lst}
This returns:
{'A': ['1', '2', '3'], 'B': ['4', '5', '6']}