How to create a dictionary with keys as strings and values as lists in Python

1 Answer

0 votes
keys = ['key1', 'key2', 'key3', 'key4']

dic = {key: [0, 0] for key in keys}

print(dic)

 
 
'''
run:
 
None

{'key1': [0, 0], 'key2': [0, 0], 'key3': [0, 0], 'key4': [0, 0]}

'''

 



answered Dec 17, 2024 by avibootz
...