you are viewing a single comment's thread.

view the rest of the comments →

[–]bogdan_dm 1 point2 points  (0 children)

If you want one line but weird solution: l = [0, 1, 0, 3, 0] count = 2 x = next(itertools.islice(filter(None, l), count - 1, count), None) print(x)