Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

modify a list with for loop and range function in python

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

for index in range(len(cities)):
    cities[index] = cities[index].title()

print(cities)

# output - ['New York City', 'Mountain View', 'Chicago', 'Los Angeles']
Source by www.udacity.com #
 
PREVIOUS NEXT
Tagged: #modify #list #loop #range #function #python
ADD COMMENT
Topic
Name
2+1 =