Hi,
I'm new to Python, and found some problems on the internet that would be a
good start to begin. The problem I have is that my conversion program (which
currently only converts unsigned integers) also prints all these brackets
and commas. Here is my code and the result:
CODE:
print ""
print "--------------------"
print "Unsigned Binary"
print "--------------------"
print ""
n = int(raw_input("Please enter an integer: "))
b = ''
while n > 0:
r = n%2
n = n/2
b = r,b
print b
(ex: n = 15)
RESULT:
(1, (1, (1, (1, ''))))
I think the problem is in the line of code 'b = r,b', but am not sure how to
fix it. The tip given for the problem says I should 'append' r to b, but
since b is not a list, 'b = r,b' was the only thing that came to my mind.
Thanks in advance.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor