dictionary function fromkeys in python code example
Example 1: dictionary function fromkeys in python
key = { "India", "Austria", "USA", "Pakistan", "Czech Republic"}
value = "Country"
countries = dict.fromkeys(key, value)
counties
'Pakistan': 'Country',
'Austria': 'Country',
'India': 'Country',
'Czech Republic': 'Country'}
Example 2: fromkeys in python
sequence1={1,2,3}
sequence2={"a","b","c"}
values1="Numbers"
values2="Alphabets"
dict1.fromkeys(sequence1,values1)
dict2.fromkeys(sequence2,values2)