fromkeys() method in Python is used to return a new dictionary.
fromkeys() method requires two parameters. One is an iterable that contains the keys of the dictionary to be returned.
The second parameter is the value of all the keys, and is an optional argument.
If the second argument is not passed, the default value of the keys is set to
dictionary = dict.fromkeys(['1', '2,', '3'], '420') print(dictionary)
#Dictionary created without optional values argument dictionary = dict.fromkeys(['1', '2', '3']) print(dictionary)
View all Courses