@RyanMarcus/

reversed-prefix

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
a = [1, 2, 3, 4, 5]


compre = (reversed(a[-i:]) for i in range(len(a)))

for el in compre:
  print(list(el))


def reversed_prefix(a):
  tmp = []
  for el in reversed(a):
    tmp.append(el)
    yield tmp

for el in reversed_prefix(a):
  print(el)