Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to enumerate the names inside a list python

names = ["David", "Sarah", "Matt"]

# i is used for the numbers and name for the names
for i, name in enumerate(names):
# i + 1 so the enumeration starts from one not zero
    print(i + 1 , name)

#output:
# 1 David
# 2 Sarah
# 3 Matt
 
PREVIOUS NEXT
Tagged: #enumerate #names #list #python
ADD COMMENT
Topic
Name
7+3 =