Re: [Tutor] enhanced subtration in an exponent

2015-04-21 Thread Dave Angel
On 04/20/2015 08:44 PM, Jim Mooney wrote: Why does the compiler choke on this? It seems to me that the enhanced subtraction resolves to a legitimate integer in the exponent, but I get a syntax error: B = '11011101' sum = 0 start = len(B) for char in B: sum += int(char) * 2**(start -= 1) ##

Re: [Tutor] enhanced subtration in an exponent

2015-04-21 Thread Alan Gauld
On 21/04/15 01:44, Jim Mooney wrote: Why does the compiler choke on this? It seems to me that the enhanced subtraction resolves to a legitimate integer That's your mistake. Assignment is a statement not an expression. It does not return anything. In fact its just illegal to try: >>> print x=

Re: [Tutor] enhanced subtration in an exponent

2015-04-21 Thread Danny Yoo
On Apr 21, 2015 12:24 AM, "Jim Mooney" wrote: > > Why does the compiler choke on this? It seems to me that the enhanced > subtraction resolves to a legitimate integer in the exponent, but I get a > syntax error: > > B = '11011101' > sum = 0 > start = len(B) > for char in B: > sum += int(char)

[Tutor] enhanced subtration in an exponent

2015-04-21 Thread Jim Mooney
Why does the compiler choke on this? It seems to me that the enhanced subtraction resolves to a legitimate integer in the exponent, but I get a syntax error: B = '11011101' sum = 0 start = len(B) for char in B: sum += int(char) * 2**(start -= 1) ## syntax error print(sum) -- Jim ___