“enumerar” Respostas de código

para enumerar python

for key, value in enumerate(["p", "y", "t", "h", "o", "n"]):
    print key, value

"""
0 p
1 y
2 t
3 h
4 o
5 n
"""
Weary Wombat

Python enumerar para loop

presidents = ["Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson"]
for num, name in enumerate(presidents, start=1):
    print("President {}: {}".format(num, name))
Yawning Yacare

enumerar

array = ["one","two","three","four"]
arrayOfNumbers = []
mainArray = []

for i, x in enumerate(array):
	arrayOfNumbers.append(i)
    mainArray.append(x)
    
'''
>>print(arrayOfNumbers)
>>[0, 1, 2, 3]


>>print(mainArray)
>>["one","two","three","four"]

'''
Burak Bulama

enumerar

# enumerate
for index, item in enumerate(['sanjose', 'cupertino', 'sunnyvale', 'fremont']):
  print(index, ':', item)
  
# 0 : sanjose
# 1 : cupertino
# 2 : sunnyvale
# 3 : fremont 
Impossible Impala

Respostas semelhantes a “enumerar”

Perguntas semelhantes a “enumerar”

Procure respostas de código populares por idioma

Procurar outros idiomas de código