Can I put two lists in one dictionary as keys and values?
a=["Apple", "Banana", "Pineapple"] b=[1,2,3] When
dic={'Apple':1, 'Banana':2, 'Pineapple':3}
Can you put it in order like this?
dictionary list key value python
You can use the zip.
dic = { name:value for name, value in zip(a, b) }
© 2024 OneMinuteCode. All rights reserved.