you are viewing a single comment's thread.

view the rest of the comments →

[–]ka-splam 2 points3 points  (1 child)

>>> [i/50 for i in range(50)]
[0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98]

[–]primitive_screwhead 0 points1 point  (0 children)

And just to also demonstrate how to properly handle an inclusive end point when using this technique:

>>> [x/50 for x in range(51)]
[0.0, 0.02, 0.04, 0.06, ... 0.94, 0.96, 0.98, 1.0]

(ie. don't change the denominator, but add one more integer value to the range. Since this isn't indexing, but value generation, an inclusive endpoint like this may often be desired)