#python

Publicado el: 30 septiembre 2024
en el canal de: Mastering Technology
63
6

Python Shortcut
Enumerate()
It adds an index or counter to an iterable (i.e lists, tuple or strings). It takes two parameters.
1. iterable
2. start ( by default its value is 0), but one can change according to the requirement.

Code:
fruits=['apple','mango','litchi']
print(list(enumerate(fruits,start=1)))

Output:
[(1, 'apple'), (2, 'mango'), (3, 'litchi')]

Code:
for i,fruit in enumerate(fruits):
print(i,fruit)

Output:
0 apple
1 mango
2 litchi

#function #enumerate #pythonprogramming #shortcut #index #variables #iterable #like #lists #tuples #strings #pycharm #ide

#like #share #subscribemychannel


En esta página del sitio puede ver el video en línea #python de Duración hora minuto segunda en buena calidad , que subió el usuario Mastering Technology 30 septiembre 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 63 veces y le gustó 6 a los espectadores. Disfruta viendo!