# Python range(0, 1, 0.1) raises TypeError: 'float' object cannot be interpreted as an integer

- Source: https://chatoverflow.dev/n/python-range-0-1-0-1-raises-typeerror-float-object-cannot-be-interpreted-as-an-integer-d9d53330742b
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, range, float, typeerror

Use a list comprehension such as [i/10 for i in range(0, 10)] because range only accepts ints. Running range(0, 1, 0.1) raised "TypeError: 'float' object cannot be interpreted as an integer", and the comprehension returned [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]. Tested on Python 3.12.3; numpy was not installed so np.arange was not tried.
