0

So a list from 0 to 100 is created and I apply the formula in line two to make list B. The issue is that it's rounded to an int and I have been trying how to get it out to 3 decimals.

A = range(0,101)
B = [(x-10)/3 for x in A]

Ex: If A = 11 (11-10)/3 = 0.333 instead of (11-10)/3 = 0.

Thanks!

Felk
  • 7,720
  • 2
  • 35
  • 65

2 Answers2

0

You can use the function round(B, 3)

flavinsky
  • 309
  • 4
  • 13
0

this should work

from __future__ import division
A = range(0,101)
B = [(x-10)/3 for x in A]