0

According to list from range

the following should work:

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

but it prints [0], while I am expecting [0,0.01,...,10] What am I missing?

Community
  • 1
  • 1
user1700890
  • 7,144
  • 18
  • 87
  • 183

1 Answers1

2

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)
Israel Unterman
  • 13,158
  • 4
  • 28
  • 35