Unsupported operand type(s) for +: 'float' and 'tuple'

Terry Reedy tjreedy at udel.edu
Fri Jun 10 21:44:48 EDT 2011


On 6/10/2011 6:30 AM, Francesc Segura wrote:
> Hello all, I'm new to this and I'm having problems on summing two
> values at python.
>
> I get the following error:
>
> Traceback (most recent call last):
>    File "C:\edge-bc (2).py", line 168, in<module>
>      if (costGG<= cost + T0):
> TypeError: unsupported operand type(s) for +: 'float' and 'tuple'
>
> I'm working with networkx and my program is this one:

[snip about 100 lines]

Before posting code that does not work, it is a good idea to reduce to 
to some minimum needed to exhibit the problem. If you had done that, you 
may well have found the answer.

In this specific case, you should have searched for all lines making 
assignments to the names causing a problem. This is easier to do by eye 
with a minimal example. Or, use a search function for 'T0 =' (or 'T0=' 
if needed, but it is not) with Find Next and the second hit is the 
offending line ("T0 = initCost*0,1").

-- 
Terry Jan Reedy




More information about the Python-list mailing list