Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

enumerate

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"]

'''
Comment

# enumerate

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

PREVIOUS NEXT
Code Example
Python :: append in python 
Python :: how to comment text in python 
Python :: numpy copy a array vertical 
Python :: pytorch squeeze 
Python :: django change settings at runtime 
Python :: python multiply string 
Python :: pandas resample friday 
Python :: python how to remove n from string 
Python :: torch print full tensor 
Python :: access column pandas 
Python :: python how to add a string to a list in the middle 
Python :: python command line keyword arguments 
Python :: flask where to put db.create_all 
Python :: django unique validator 
Python :: get files in directory and subdirectory 
Python :: python string to operator 
Python :: convert dictionary keys to list python 
Python :: python ternary elif 
Python :: slicing of strings in python 
Python :: remove french stopwords with spacy 
Python :: align a text python 
Python :: from django.core.management import execute_from_command_line ImportError: No module named django.core.management 
Python :: Remove whitespace from str 
Python :: check space in string python 
Python :: tkinter tutorial 
Python :: class inside class python 
Python :: python linear fit 
Python :: tensorflow neural network 
Python :: choose value none in pandas 
Python :: how to change entry in a row based on another columns entry python 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =