📌  相关文章
📜  使用for循环python代码示例遍历列表并从索引x打印到y

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

代码示例2
fruits = ["apple", "orange", "banana", "orange", "mango", "strawberry", "lichi", "tangerine", "kiwi", "pineapple"]
start_from = 1
end_before = 8
increment_by = 2
for i in range(start_from, end_before, increment_by):  # This will not work for sets as sets are not ordered
    print(f"{i + 1}. {fruits[i]}")