You can either use:

[x / 10.0 for x in range(5, 50, 15)]

or use lambda / map:

map(lambda x: x/10.0, range(5, 50, 15))
Answer from Grzegorz Rożniecki on Stack Overflow
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python range() with float values
Python range() with float values - Spark By {Examples}
May 31, 2024 - Example 2: Let’s generate float values by specifying the num parameter. import numpy as np # Using np.linspace() with num parameter for i in np.linspace(1.5, 5.5,num=5): print(i, end=', ') # Output: # 1.5, 2.5, 3.5, 4.5, 5.5, We specified the num parameter and set it to 5. So only 5 values are generated within the given range. You have learned that the Python range() function won’t support generating the float values.
Discussions

python - How do I use a decimal step value for range()? - Stack Overflow
I did a xfrange function without the float precision problems referred above. Check it out ;) stackoverflow.com/questions/477486/… 2013-12-12T17:05:29.957Z+00:00 ... You're accumulating rounding errors. Please use this instead: ` i = 0; r = start while r < stop: i += 1; r = start + i * step; yield r` 2016-04-11T11:56:21.267Z+00:00 ... This is from pythoncentral.io/pythons-range... More on stackoverflow.com
🌐 stackoverflow.com
float numbers with range () function
Yes, range(0, 101) literally gives the integers from 0 to 100. If you want to know if a number is between two values, use a chained comparison: while 0 <= score < 101: Although note you shouldn't get an actual error, just a False. What exact error message did you see? More on reddit.com
🌐 r/learnpython
4
2
April 19, 2022
Float contained in range - Ideas - Discussions on Python.org
I have found that checking if a float number falls inside a range() doesn’t work, always giving False: >>> 1.0 in range (0, 2) True >>> 1.5 in range (0, 2) False I can understand that range() can only accept integer values, but checking if it contains a float number should works. More on discuss.python.org
🌐 discuss.python.org
0
September 7, 2023
python - Range with step of type float - Stack Overflow
More specific: How would I translate ... to Python in a nice way (i.e. not just doing it via a while-loop manually): ... You can't have return and yield keywords in that loop, use break. ... Looks like you can! I didn't think that was possible.. I'm sure errors have been raised when I tried something similar ... Take the code example you posted, rename it to float_range - ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
PYnative
pynative.com › home › python › python range of float numbers
Python range of float numbers
April 13, 2021 - ... Import numpy module using the import numpy as np statement. ... Pass float numbers to its start, stop, and step argument. For example, np.arange(0.5, 6.5, 1.5) will return the sequence of floating-point numbers starting from 0.5 up to 6.5.
🌐
TechBeamers
techbeamers.com › python-float-range
Generate Floating Point Range in Python - TechBeamers
November 30, 2025 - start = 1 stop = 6.7 step = 0.1 for value in range(start, stop, step): print (value) When you run the above code, it throws the following error: TypeError: 'float' object cannot be interpreted as an integer · The above example suggests that ...
🌐
Codingem
codingem.com › home › range of floats in python: a step-by-step guide (3 ways to do it)
Range of Floats in Python: A Step-by-Step Guide (3 Ways to Do It)
November 1, 2022 - To create a range of floats in Python, use a list comprehension. For example: [(x/10) for x in range(0, 5)] returns [0.0, 0.1, 0.2, 0.3, 0.4]
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-range-for-float-numbers
Python - range() for Float Numbers - GeeksforGeeks
July 23, 2025 - For a cleaner solution, we can use numpy, which provides a function called arange(). It works just like range(), but it supports floats. ... If we don’t want to use numpy, we can create our own function to mimic the behavior of range() for floats.
🌐
Delft Stack
delftstack.com › home › howto › python › python range float
How to Get Range of Floating Numbers in Python | Delft Stack
February 2, 2024 - The below example code demonstrates how to get the range or sequence of float values in Python using the list comprehension method.
Find elsewhere
🌐
Guru99
guru99.com › home › python › python range() function: float, list, for loop examples
Python range() Function: Float, List, For loop Examples
August 12, 2024 - Let us now work on the range() using floating-point numbers. ... In above example we have used stop value as 10.5. ... Traceback (most recent call last): File "python_range.py", line 1, in <module> for i in range(10.5): TypeError: 'float' object cannot be interpreted as an integer
🌐
TutorialKart
tutorialkart.com › python › python-range › python-range-float
Python Range with Floating Point Numbers
January 17, 2021 - ... start = 0 stop = 0.9 step = 0.1 scale = 10 for i in range(int(scale*start), int(scale*stop), int(scale*step)) : print(i/scale) ... You may have to change the scale based on the start, stop, and step values.
🌐
Javatpoint
javatpoint.com › range-of-float-in-python
Range of float in python - Javatpoint
Range of float in python with tutorial, tkinter, button, overview, canvas, frame, environment set-up, first python program, etc.
🌐
Reddit
reddit.com › r/learnpython › float numbers with range () function
r/learnpython on Reddit: float numbers with range () function
April 19, 2022 -

Hi, I have a section of code which takes a score from the user, typecasts it into a float value and saves it under the variable name "score". Then I have a line of code which reads:

while score not in range(0, 101):

However, when I input a float, I get an invalid input error message from python. I think it's because I can't use the range() function with floats. Is there a way around this? If anyone knows how to solve this, then your help would be greatly appreciated. Thank you in advance.

🌐
GeeksforGeeks
geeksforgeeks.org › python-range-for-float-numbers
Python – range() for Float Numbers | GeeksforGeeks
December 4, 2024 - ... # Initialize the starting, ... in Python means producing a decimal number that falls within a certain range, often between 0.0 and 1.0....
🌐
BitDegree
bitdegree.org › learn › best-code-editor › python-range-example-4
How to Make a Python Range With Float Values
Python range only allows integers, but you can make it accept float values by using frange() instead of range(). Learn to create Python range with floats!
🌐
YouTube
youtube.com › data science tutorials
Python 3 Programming Tutorial | How to create range values for float data type - YouTube
In this python 3 programming tutorial, I have talked about how you can create range of float values which is directly not possible using the range function. ...
Published   July 4, 2018
Views   1K
🌐
Simplilearn
simplilearn.com › home › resources › software development › python float() function: key concepts [with examples]
Python float() Function: Key Concepts [With Examples]
November 27, 2024 - Learn how the float() function in Python converts a specified value into a floating point number. Syntax: float(value). A key function for numeric conversions.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Note.nkmk.me
note.nkmk.me › home › python
Maximum and Minimum float Values in Python | note.nkmk.me
August 11, 2023 - In Python, the float type is a 64-bit double-precision floating-point number, equivalent to double in languages like C. This article explains how to get and check the range (maximum and minimum values ...
🌐
Python.org
discuss.python.org › ideas
Float contained in range - Ideas - Discussions on Python.org
September 7, 2023 - I have found that checking if a float number falls inside a range() doesn’t work, always giving False: >>> 1.0 in range (0, 2) True >>> 1.5 in range (0, 2) False I can understand that range() can only accept integer va…
🌐
Coursera
coursera.org › tutorials › python-range
How to Use Range in Python | Coursera
Stop is the only required parameter because it tells Python which integer number will end the sequence. For example, suppose you want the range to start at 0 and stop at 5 (not including 5).