On Sat, 15 Dec 2007 16:46:38 -0800, Dennis Lee Bieber wrote:

> ... this becomes trivial... So trivial I'm going to include a solution,
> even though it is a homework assignment...
> 
>>>> inp = raw_input("Enter the sequence of 1 and 0: ") print inp
> 1001101011101011101
>>>> print "The count is %s" % len(
> ...           [c for c in inp if c == "1"]    )
> The count is 12


*cough*

It's even more trivial than that.

>>> '1001101011101011101'.count('1')
12



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to