Вы имели в виду это?
$ python
Python 2.5.5 (r255:77872, Apr 21 2010, 08:40:04)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(x):
... return x>0 and (x%2)+f(x/2) or 0
...
>>> f([1, 1, 1, 3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in f
TypeError: unsupported operand type(s) for %: 'list' and 'int'