<[EMAIL PROTECTED]> wrote
> I'm trying to get this binary converter working, but I can't seem to
> get the
> negatives to work properly.
I already sent a reply on this, but:
> def conversion(n):
> b = ''
> while n > 0:
This line means you only ever return an empty string for a negative
n...
> n = int(raw_input("Please enter a signed integer: "))
> bits = int(raw_input("Please enter the number of bits: "))
> count = conversion(n).count("0") + conversion(n).count("1")
And you call it with anegative n here and use the empty
string to calculate the count... => 0.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor