Search
 
SCRIPT & CODE EXAMPLE
 

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']
Comment

PREVIOUS NEXT
Code Example
Python :: download latest chromedriver python code 
Python :: get files in directory and subdirectory 
Python :: is fastapi better than flask 
Python :: string python 
Python :: any python 
Python :: poerty python macos 
Python :: Customize color stacked bar chart matplotlib 
Python :: dict in dict in python 
Python :: dictionary changed size during iteration 
Python :: shrink colorbar matplotlib 
Python :: ubuntu python3 as python 
Python :: doc strings python 
Python :: tkinter canas can you use other fonts 
Python :: python to linux executable 
Python :: python jinja2 from string 
Python :: python keyboard hold key 
Python :: matplotlib default style 
Python :: how to append two pandas dataframe 
Python :: How to count the occurrence of certain item in an ndarray? 
Python :: for loop with index python 
Python :: python for data analysis 
Python :: python unpacking 
Python :: plynomial regression implementation python 
Python :: How to take multiple inputs in one line in python using split() 
Python :: how to download file using python using progress bar 
Python :: python why call super(class).__init__() 
Python :: convert int to float python 
Python :: python tableau 
Python :: add two strings together 
Python :: how to concatenate two lists in python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =