Scenario: A dictionary contains many lists that I want to extract. Psuedocode: E.g.
Dict = {'a':[1,2,3], 'b':[2,3,4], 'c':[4,5,6]}
Result, I want to create an array named after the keys in a for loop. Is it possible?
I want a = [1,2,3], b = [2,3,4], c=[4, 5, 6]
without having to type the a = [], b = [], c = [] and append them individually, is there anyway to do this in a for loop automatically?
Result:
a = [1,2,3]
b = [2,3,4]
c = [4,5,6]
My current solution: Create a class
class Container:
def __init__(self):
self.k = []
result = [Container() for i in range(4)]
for i,k in enumerate(Dict.keys()):
result[i] = Dict[k]
Is there any faster solution?