Combining two lists into a dictionary in python -
this question has reply here:
map 2 lists dictionary in python 9 answersfor example, if had 2 lists:
lista = [1, 2, 3, 4, 5] listb = [red, blue, orange, black, grey]
i'm trying figure out how display elements in 2 argument lists in 2 columns, assigning 1: red, 2: blue...
, on.
this has done without using built-in zip
function.
>>> lista = [1, 2, 3, 4, 5] >>> listb = ["red", "blue", "orange", "black", "grey"] >>> dict(zip(lista, listb)) {1: 'red', 2: 'blue', 3: 'orange', 4: 'black', 5: 'grey'}
python list dictionary
No comments:
Post a Comment