📜  在 python 代码示例中使用 for 循环和范围函数修改列表

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

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