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

enumerate()

>>> users = ["Test User", "Real User 1", "Real User 2"]
>>> for index, user in enumerate(users):
...     if index == 0:
...         print("Extra verbose output for:", user)
...     print(user)
Comment

PREVIOUS NEXT
Code Example
Python :: python map function 
Python :: get admin url of instance django 
Python :: for loop in python array 
Python :: save artist animation puython 
Python :: pyhton dms to decimal 
Python :: Making a delete request using python 
Python :: os.listdir specific extension 
Python :: element not interactable headless chrome 
Python :: get processor model in python 
Python :: how to get a list of files in a folder in python with pathlib 
Python :: sum the contents of a list python 
Python :: use model from checkpoint tensorflow 
Python :: conditional subsetting python 
Python :: python cv2 unblur 
Python :: python os path safe string 
Python :: ascii to int python 
Python :: dataframe multiindex query 
Python :: selenium screenshot python user agent 
Python :: pandas assign value to row based on condition 
Python :: __add__ 
Python :: pip ne marche pas 
Python :: Python NumPy ascontiguousarray Function Example Scalar to an array 
Python :: python zip file 
Python :: Fibonacci series up to n python 
Python :: how to save string json to json object python 
Python :: noob python 
Python :: python utf upper() 
Python :: append numeric number in and auto increment in using pandas 
Python :: truncate spaces in python 
Python :: python take input without displaying it 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =