有没有办法在循环使用for循环时访问列表(或元组,或其他可迭代)的下一个或前一个元素?
l=[1,2,3] for item in l: if item==2: get_previous(l,item)
python
python ×1