📜  python for 循环从索引开始,枚举 - Python 代码示例

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

代码示例2
items_list = ["python","enumerate","function","with","custom","start"]

custom_start = 1 # default_start = 0

for index,item in enumerate(items_list, start = custom_start):
     if index == 1:
         print("index starts at {custom_start} with a stored value of {list_value}".format(custom_start=index, list_value=item))
     else:
         print("index continues as {} with a value of {}".format(index,item))