1key = { "India", "Austria", "USA", "Pakistan", "Czech Republic"}
2value = "Country"
3countries = dict.fromkeys(key, value) # function fromkeys
4counties
5#returns {'USA': 'Country',
6 'Pakistan': 'Country',
7 'Austria': 'Country',
8 'India': 'Country',
9 'Czech Republic': 'Country'}
1
2 x = ('key1', 'key2', 'key3')
3y = 0
4
5thisdict = dict.fromkeys(x, y)
6
7
8print(thisdict)
9
10//Output:{'key1': 0, 'key2': 0, 'key3': 0}
11
12
1sequence1={1,2,3}
2sequence2={"a","b","c"}
3values1="Numbers"
4values2="Alphabets"
5dict1.fromkeys(sequence1,values1)
6#returns {1: 'Numbers', 2: 'Numbers', 3: 'Numbers'}
7
8dict2.fromkeys(sequence2,values2)
9#returns {'c': 'Alphabets', 'b': 'Alphabets', 'a': 'Alphabets'}
10