What I'm trying to achieve:
l = []
n = 100
while (n):
l.append(n//2)
n //= 2
print(l)
# [50, 25, 12, 6, 3, 1, 0]
What I've tried:
>>> from itertools import takewhile
>>> n = 100
>>> [(n := n//2) for _ in takewhile(lambda x: x > 0, [n] * n)]
[50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, ... 0, 0, 0]
This clearly doesn't work, and I also don't like the idea of creating an array of size n...