« * K @trey.io

Trey Hunner @trey.io

2026-11-24 04:16 UTC

Python Tip #327 (of 365): Loop over neighboring items with pairwise. 🧵 Do this: for day, next_day in pairwise(days): print(day, next_day) Not this: iterator = iter(days) day = next(iterator) for next_day in iterator: print(day, next_day) day = next_day #Python #DailyPythonTip

Link: Avoid indexes in Python (pym.dev/avoid-indexes-in-python/#other-looping-helpers-to-h…)

5 likes, 0 reposts, 1 replies

3 Next post4 More from @trey.ioBackBluesky home
☆ Save to home · 0 Home · Find · Games · Chat · AI · Setup