440,715 Members | 748 Online
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

# to calculate the universal distribution of continued fraction expansion

 P: 2 Hi all, I'm studying python program in uni. my lecture asks us to calculate the universal distribution of continued fraction expansion But I always have an error says: TypeError: 'builtin_function_or_method' object is not subscriptable. here's my algorithm: Expand|Select|Wrap|Line Numbers def universal_distro(N=10000):         import random     x = random.random()     g = list()     m = dict()     o = dict()     N = len(o)     while N < 10000:         for x in range[0,1]:             w = number2cfe(x,N=15)             e = w[n]             if n < 15:                 count = 0                 if w[n] not in g:                     for e in w:                         if e == w[n]:                             count += 1                     g.append(w[n])                 n += 1                 m[w[n]] = count         for k in m.keys():             if o.has_key(k):                 o[k] += m[k]             else:                 o[k] = m[k]         N += 1     return o   >>> universal_distro(10000) File "", line 9, in universal_distro     for x in range[0,1]: TypeError: 'builtin_function_or_method' object is not subscriptable   Can someone help me out? thanks Sep 3 '11 #1