2021-06-30

I need to make a dictionary from a list of lists

I have this:

A = [[0, 3, 6, 11], [0, 5, 7, 11], [0, 1, 2, 4, 8, 9, 10, 11]]

I want to make a diccionary from A like this:

dic_A = { 0: [0, 3, 6, 11], 1: [0, 5, 7, 11], 2: [0, 1, 2, 4, 8, 9, 10, 11]}

I have tried different ways and I can only use a for in range to solve the problem I think this can be reduced to a line somehow but I can't find the way

I tried this:

    dic_A = {}
    for i in range(3):
         dict_A[i] = A[i]
        
          


from Recent Questions - Stack Overflow https://ift.tt/3drMOjT
https://ift.tt/eA8V8J

No comments:

Post a Comment