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


Groups > comp.lang.python > #41220

Re: TypeError: 'float' object is not iterable

References <3984882c-0144-47ba-af4f-b29877bc4698@googlegroups.com>
Date 2013-03-14 06:31 -0400
Subject Re: TypeError: 'float' object is not iterable
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3291.1363257065.2939.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Mar 14, 2013 at 6:12 AM, Ana Dionísio <anadionisio257@gmail.com>wrote:

> Hi!!
>
> I keep having this error and I don't know why: TypeError: 'float' object
> is not iterable.
>
> I have this piece of code, that imports to python some data from Excel and
> saves it in a list:
>
> "
> t_amb = []
>
> for i in range(sh2.nrows):
>     t_amb.append(sh2.cell(i,2).value)
>
> print t_amb
>
> "
> Here is everything ok.
>
> But then, I need to pass the data again to exel, so I wrote this:
>
> "
> a=8
> for b in range (len(t_amb)):
>     a=8
>     for d in t_amb[b]:
>         a=a+1
>         sheet.write(a,b+1,d)
> "
>
> The error appear in "for d in t_amb[b]:" and I don't understand why. Can
> you help me?
>

Most likely the value of t_amb[[b] is a float.  It would have to be a list
or a tuple or some other sequence to be iterable.  I can't tell what you
are trying to do here

> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

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


Thread

TypeError: 'float' object is not iterable Ana Dionísio <anadionisio257@gmail.com> - 2013-03-14 03:12 -0700
  Re: TypeError: 'float' object is not iterable Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-14 06:31 -0400
    Re: TypeError: 'float' object is not iterable Ana Dionísio <anadionisio257@gmail.com> - 2013-03-14 03:34 -0700
      Re: TypeError: 'float' object is not iterable Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-14 06:44 -0400
      Re: TypeError: 'float' object is not iterable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-03-14 18:09 -0400
    Re: TypeError: 'float' object is not iterable Ana Dionísio <anadionisio257@gmail.com> - 2013-03-14 03:34 -0700
  Re: TypeError: 'float' object is not iterable MRAB <python@mrabarnett.plus.com> - 2013-03-14 10:43 +0000
  Re: TypeError: 'float' object is not iterable Chris Rebert <clp2@rebertia.com> - 2013-03-14 03:50 -0700
  Re: TypeError: 'float' object is not iterable John Ladasky <john_ladasky@sbcglobal.net> - 2013-03-14 11:11 -0700

csiph-web