How to create a new dictionary from the keys of a given dictionary with default value in Python

1 Answer

0 votes
dict = {
    "name": "Tom",
    "age": 47,
    "langauge": "python", 
    "company":  "microsoft"}
      
newdict = dict.fromkeys(dict, 3)

print(dict)

print(newdict)


  
  
'''
run:
  
{'name': 'Tom', 'age': 47, 'langauge': 'python', 'company': 'microsoft'}
{'name': 'Tom', 'age': 47, 'langauge': 'python', 'company': 'google'}
 
'''

 



answered Jan 13, 2021 by avibootz
...