user1700890 user1700890 - 1 year ago 119
Python Question

python 3 list from range

According to list from range

the following should work:

x = list(range(0, 10, 100))

but it prints
, while I am expecting
What am I missing?

Answer Source

range doesn't do fractions. Also the third argument is the step, that is:

range(start, stop, step)

To get what you want with fractions you can use numpy arrays. For example:

import numpy as np
x = np.linspace(0, 10, 100)