-
-
Save IndhumathyChelliah/ccefe6feb0936b700d389bc48410a5ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#fromkeys() | |
#fromkeys() method returns a dictionary with the specified keys and the specified value. | |
a={'a','e','i','o','u'} | |
b='vowels' | |
d1=dict.fromkeys(a,b) | |
print(d1) | |
#Output: {'o': 'vowels', 'u': 'vowels', 'e': 'vowels', 'i': 'vowels', 'a': 'vowels'} | |
#dictionary is unordered. | |
#if value is not mentioned,it defaults to None. | |
d2=dict.fromkeys(a) | |
print (d2)#Output:{'e': None, 'a': None, 'u': None, 'i': None, 'o': None} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment