Ejemplo 1: función de diccionario fromkeys en python
key = { "India", "Austria", "USA", "Pakistan", "Czech Republic"}
value = "Country"
countries = dict.fromkeys(key, value) # function fromkeys
counties
#returns {'USA': 'Country',
'Pakistan': 'Country',
'Austria': 'Country',
'India': 'Country',
'Czech Republic': 'Country'}
Ejemplo 2: fromkeys en python
sequence1={1,2,3}
sequence2={"a","b","c"}
values1="Numbers"
values2="Alphabets"
dict1.fromkeys(sequence1,values1)
#returns {1: 'Numbers', 2: 'Numbers', 3: 'Numbers'}
dict2.fromkeys(sequence2,values2)
#returns {'c': 'Alphabets', 'b': 'Alphabets', 'a': 'Alphabets'}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)