Reputation: 73
I am trying to fetch the values from an list containing float values which throws the following error,
list = [0.98,0.97,0.95,0.96,0.99,0.99]
for a in list:
if list[a] >=0.98:
print("some output")
Error:
TypeError: list indices must be integers, not float
Upvotes: 0
Views: 287
Reputation: 71570
a
is already the value, so you can do:
for a in list:
if a >=0.98:
print("some output")
If it was the index, your code will work, but since it isn't, you have to do mine.
Upvotes: 8