Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

modify a list with for loop function in python

cities = ['new york city', 'mountain view', 'chicago', 'los angeles']

for index, value in enumerate(cities):
    cities[index] = value.title()

print(cities)

# output - ['New York City', 'Mountain View', 'Chicago', 'Los Angeles']
 
PREVIOUS NEXT
Tagged: #modify #list #loop #function #python
ADD COMMENT
Topic
Name
6+9 =