How to create a dictionary with a list of keys in Python

1 Answer

0 votes
lst = ["python", "java", "swift"]

dic = dict.fromkeys(lst, 12)

print(dic)

print(dic.get("python"))

    
    
    
'''
run:

{'python': 12, 'java': 12, 'swift': 12}
12

'''

 



answered Oct 22, 2020 by avibootz
...