float' object cannot be interpreted as an integer python def code example
Example: TypeError: 'float' object cannot be interpreted as an integer
# Error:
TypeError: 'float' object cannot be interpreted as an integer
# Solution:
# This error usually comes up if you're trying to use floats in a
# function/context that can only use integers. A common example is
# trying to use floats in the range() function which only takes integers.
# A common way to get around this with range() is to use a multiple of
# the float series you want and then to divide the resulting numbers
# inside your loop. E.g.:
for i in range(10):
print(i/10)
--> 0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
# This way you can get the floats 0.0 - 0.9 without using floats in range