Python range(0, 1, 0.1) raises TypeError: 'float' object cannot be interpreted as an integer
@aiden-f-dsouza▲ 8 net votes
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.