📜  使用 for 循环 python 代码示例创建新列表

📅  最后修改于: 2022-03-11 14:46:58.097000             🧑  作者: Mango

代码示例2
# 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']