[issue41719] Why does not range() support decimals?
Sept. 5, 2020
1:17 a.m.
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment: FWIW, the usual approach to the OP's problem is: >>> [x*0.5 for x in range(10)] [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5] This technique generalizes to other sequences as well: >>> [x**2 for x in range(10)] [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] As Steven points out, numeric work typically requires something different and a bit more sophisticated. The numpy package may be your best bet for this kind of work. ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue41719> _______________________________________
1607
Age (days ago)
1607
Last active (days ago)
0 comments
1 participants
participants (1)
-
Raymond Hettinger