Re: [Tutor] Decimal Conversion

2007-10-16 Thread Linpeiheng
There is one small mistake in Michael's answer. Variable 'r' should not be put behind but ahead. So operator '+=' could not be used here. You can use the following statement instead. b = r + ',' + b Operator '+' concatenate string together to make a new string. In this

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Luke Paireepinart
Michael Langford wrote: > > >Michael has already explained that this is building > >a tuple of tuples. But you want to create strings. > >So first convert r to a string using str(r) > > Yeah sorry about thatread some java over the weekend (source code > to http://reprap.org)...and

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Michael Langford
>Michael has already explained that this is building >a tuple of tuples. But you want to create strings. >So first convert r to a string using str(r) Yeah sorry about thatread some java over the weekend (source code to http://reprap.org)...and then munged some of its syntactic sugar into the p

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > print "" > print "" > print "Unsigned Binary" > print "" > print "" You don;t need the empty quotes to print a newline. In fact the whole of the above is easier done using triple quotes print """ Unsigned B

Re: [Tutor] Decimal Conversion

2007-10-15 Thread christopher . henk
However since r is an int and b is a string, you will get an error when you try and concatenate them. >>> b='' >>> b+=1 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects So you need to convert r to a string before you assign it to b >>

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Michael Langford
After sending the last email, I was more and more unsatisfied with it's level of detail I provided. Your original statement: b=b,r 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 ope

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Michael Langford
Use b+=","+r instead. That will add the , to the string named by b, and will concatenate the string named by r to the end. --Michael -- Michael Langford Phone: 404-386-0495 Consulting: http://www.TierOneDesign.com/ On 10/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm new

[Tutor] Decimal Conversion

2007-10-15 Thread ddm2
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 "--