from thinkbayes2 import Pmf pmf = Pmf() for x in [1,2,3,4,5,6,7]: pmf.Set(x, 1/6.0) pmf.Normalize() print (pmf.Prob(4))