close

[Solved] TypeError: ‘float’ object not iterable

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error TypeError: ‘float’ object not iterable in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How TypeError: ‘float’ object not iterable Error Occurs?

Today I get the following error TypeError: ‘float’ object not iterable in python.

How To Solve TypeError: ‘float’ object not iterable Error ?

  1. How To Solve TypeError: 'float' object not iterable Error ?

    To Solve TypeError: 'float' object not iterable Error my_data=b['dataset']['data'][0][1] useful_data=[i[1] for i in my_data]
    So when you compile it gives you an error:

  2. TypeError: 'float' object not iterable

    To Solve TypeError: 'float' object not iterable Error my_data=b['dataset']['data'][0][1] useful_data=[i[1] for i in my_data]
    So when you compile it gives you an error:

Solution 1

You have a mistake, try:

new = []
for i in A:
    new.append([i])

Here is more beautiful solution:

new = [[i] for i in A]

Solution 2

I think you are using like that:

my_data=b['dataset']['data'][0][1]
useful_data=[i[1] for i in my_data]

So when you compile it gives you an error:

TypeError: ‘float’ object is not iterable

Try only:

my_data=b['dataset']['data']

Then you will get your data.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read