Skip to content


Execute function for each list element in reverse

Executes the provided function once for each list element, starting from the list's last element.

def for_each_right(itr, fn):
  for el in itr[::-1]:

for_each_right([1, 2, 3], print) # 3 2 1

More like this

Start typing a keyphrase to see matching snippets.