After sending the last email, I was more and more unsatisfied with it's level of detail I provided.<br><br>Your original statement:<br><br>b=b,r<br><br>was doing nothing like you intended. The comma operator in this instance is making a tuple.
The name b was being reassigned to the new tuple created by the comma operator.<br><br>b+="," + r <br><br>Was not doing exactly what I said. What it's doing is creating a new string from the one named by b, the string literal "," , and the one named by r. After creating the string it assigns the name b to the new string.
<br><br> --michael<br clear="all"><br>-- <br>Michael Langford<br>Phone: 404-386-0495<br>Consulting: <a href="http://www.TierOneDesign.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.TierOneDesign.com/
</a>
<br><br><div><span class="gmail_quote">On 10/15/07, <b class="gmail_sendername">Michael Langford</b> <<a href="mailto:mlangford.cs03@gtalumni.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mlangford.cs03@gtalumni.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Use <br>b+=","+r <br>instead. That will add the , to the string named by b, and will concatenate the string named by r to the end.<br><br> --Michael<br><span><br>-- <br>Michael Langford<br>Phone: 404-386-0495
<br>Consulting:
<a href="http://www.TierOneDesign.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.TierOneDesign.com/</a>
</span><div><span><br><br><div><span class="gmail_quote">On 10/15/07, <b class="gmail_sendername"><a href="mailto:ddm2@sfu.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
ddm2@sfu.ca</a></b> <<a href="mailto:ddm2@sfu.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ddm2@sfu.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I'm new to Python, and found some problems on the internet that would be a<br>good start to begin. The problem I have is that my conversion program (which<br>currently only converts unsigned integers) also prints all these brackets
<br>and commas. Here is my code and the result:<br>CODE:<br>print ""<br>print "--------------------"<br>print "Unsigned Binary"<br>print "--------------------"<br>print ""
<br>n = int(raw_input("Please enter an integer: "))<br>b = ''<br>while n > 0:<br> r = n%2<br> n = n/2<br> b = r,b<br>print b<br><br>(ex: n = 15)<br>RESULT:<br>(1, (1, (1, (1, ''))))<br>
<br>I think the problem is in the line of code 'b = r,b', but am not sure how to<br>fix it. The tip given for the problem says I should 'append' r to b, but<br>since b is not a list, 'b = r,b' was the only thing that came to my mind.
<br><br>Thanks in advance.<br>_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Tutor@python.org
</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mail.python.org/mailman/listinfo/tutor
</a><br></blockquote></div><br>
</span></div></blockquote></div><br>