gpt4 book ai didi

python - 在 Python 迭代期间打印当前值和下一个值

转载 作者:太空狗 更新时间:2023-10-30 01:17:19 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate: Iterate a list as pair (current, next) in Python

在迭代列表时,我想打印列表中的当前项以及列表中的下一个值。

listOfStuff = [a,b,c,d,e]
for item in listOfStuff:
print item, <nextItem>

输出将是:

a b
b c
c d
d e

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com