📜  带索引的 python 循环 - Python 代码示例

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

代码示例6
presidents = ["Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson"]
for num, name in enumerate(presidents, start=1):
    print("President {}: {}".format(num, name))