Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7375

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

Date 2011-06-10 06:38 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: Unsupported operand type(s) for +: 'float' and 'tuple'
References <af752c9e-e949-4bec-a127-05a3fe500cbf@y30g2000yqb.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.82.1307705938.11593.python-list@python.org> (permalink)

Show all headers | View raw


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 :)

-tkc

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unsupported operand type(s) for +: 'float' and 'tuple' Francesc Segura <frsegrev@gmail.com> - 2011-06-10 03:30 -0700
  Re: Unsupported operand type(s) for +: 'float' and 'tuple' Tim Chase <python.list@tim.thechases.com> - 2011-06-10 06:38 -0500
    Re: Unsupported operand type(s) for +: 'float' and 'tuple' Francesc Segura <frsegrev@gmail.com> - 2011-06-10 05:12 -0700
  Re: Unsupported operand type(s) for +: 'float' and 'tuple' "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-06-10 22:02 -0300
  Re: Unsupported operand type(s) for +: 'float' and 'tuple' "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-06-10 22:02 -0300
    Re: Unsupported operand type(s) for +: 'float' and 'tuple' Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-06-12 19:23 +0200
  Re: Unsupported operand type(s) for +: 'float' and 'tuple' Terry Reedy <tjreedy@udel.edu> - 2011-06-10 21:44 -0400

csiph-web