lets say I have a list a
and a variable b = 1/len(a)
but when I display the value of b
it gives me 0
Asked
Active
Viewed 323 times
-9

ECQuant
- 1
- 3
-
4Are you using Python 2? In Python 2 you need to specify float division, try `b = 1./len(a)` – Vinícius Figueiredo Jun 30 '17 at 01:20
-
1Because integer 1 divided by any number larger than zero has a fractional part, and you're doing integer division where fractional parts are discarded. – Ken White Jun 30 '17 at 01:22
-
I'm using python 3 – ECQuant Jun 30 '17 at 01:22
-
2@ECQuant Are you sure? – Andrew Li Jun 30 '17 at 01:24
-
Thank you Ken White – ECQuant Jun 30 '17 at 01:25