TypeError: 'float' object is not iterable

MRAB python at mrabarnett.plus.com
Thu Mar 14 11:43:48 CET 2013


On 14/03/2013 10:12, Ana Dionísio 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?
>
t_amb is a list of float, so t_amb[b] is a float, but you can't iterate
over a float.



More information about the Python-list mailing list