I'm new to OOP, and I'm trying to write a simple class below, but I keep getting a NameError
class rng(object):
_rand_nums = [6,3,2,1]
_p = [0.1,2,0.7,0.4]
if any(i >= 1 for i in _p):
_norm = sum(_p)
_p = [i/_norm for i in _p]
When I try to run this, I get:
<ipython-input-116-097f599a4ce0> in <listcomp>(.0)
15 if any(i >= 1 for i in _p):
16 _norm = sum(_p)
---> 17 _p = [i/_norm for i in _p]
NameError: name '_norm' is not defined
What's wrong with my code? I thought I defined _norm
fine.