SHARE
TWEET

last_current with itertools.tee

DeaD_EyE Mar 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from itertools import tee
  2.  
  3.  
  4. def last_current(iterable, n=2):
  5.     iterables = tee(iterable, n)
  6.     for x, iterable in enumerate(iterables):
  7.         for _ in range(x):
  8.             next(iterable)
  9.     return zip(*iterables)
  10.  
  11. print(list(last_current(range(100,121), 4)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top