Julieta Shem ha scritto:
jak <nos...@please.ty> writes:
[...]
--8<---------------cut here---------------start------------->8---
def powers_of_2_in(n):
if remainder(n, 2) != 0:
return 0, n
else:
s, r = powers_of_2_in(n // 2)
return 1 + s, r
--8<---------------cut here---------------end--------------->8---
for n = 0 your function get stack overflow
That's right. Let's say ``assert n > 0'' before we say ``if''.
...or just:
...
if n == 0 or remainder(n, 2) != 0:
...
--
https://mail.python.org/mailman/listinfo/python-list