Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create new list with for loop python

# Creating a new list
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
capitalized_cities = []

for city in cities:
    capitalized_cities.append(city.title())
    
print(capitalized_cities)

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