Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python iterar diccionario

# Iterar sobre claves
for clave in diccionario.keys():
    haz_algo_con(clave)
    
# Iterar sobre valores
for valor in diccionario.values():
    haz_algo_con(valor)
    
# Iterar sobre pares clave-valor
for clave, valor in diccionario.items():
    haz_algo_con(clave, valor)
Comment

python iterar diccionario

edades = {'Manuel': 22, 'Susana': 19, 'Alicia': 24}
for nombre, edad in edades.items():
    print(nombre, "tiene", edad, "años")

# Resultado:
Manuel tiene 22 años
Susana tiene 19 años
Alicia tiene 24 años
Comment

PREVIOUS NEXT
Code Example
Python :: get os information python 
Python :: how to use prettytable with python 
Python :: python copy file to new filename 
Python :: python webdriver open with chrome extension 
Python :: remove emoji from dataframe 
Python :: python replace 0 in series 
Python :: how to fill nan values with mean in pandas 
Python :: strip unicode characters from strings python 
Python :: how to access variable from another function in same class in python 
Python :: read pdf py 
Python :: python find closest value in list 
Python :: list to excel python 
Python :: find a file in python 
Python :: how to only print final iteration of a for loop pyhton 
Python :: numpy get index of n largest values 
Python :: sort dictionary 
Python :: update print python 
Python :: drop duplicate rows pandas except nan 
Python :: check if back is pressed python 
Python :: python make dictionary based on list 
Python :: python assers 
Python :: adding numbers using python function 
Python :: webbrowser.google.open python 
Python :: df drop index 
Python :: print % in python 
Python :: install from github 
Python :: python apply function to dictionary values 
Python :: write text in list to text file python 
Python :: python files 
Python :: detect keypress in python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =