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

Tim Chase python.list at tim.thechases.com
Fri Jun 10 13:38:48 CEST 2011

On 06/10/2011 05: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:
> T0 = initCost*0,1

Here, you're setting T0 to the tuple "(initCost*0, 1)" == "(0, 
1)".  I think you mean to use a period instead of a comma.

You then try to add that to a float (cost), and Python doesn't 
like that.  I wouldn't either :)


More information about the Python-list mailing list