hi again! at school we were learning about perfect numbers and i thought it would be useful to write a program to find them i currently have this code:
b= 1 h= 1 factors = [1,] n = float(raw_input("what is the number?")) while h < n: if h*b == n: print h, "is not a factor" h=h+1 else: if h == 1: print h, "is a factor" h=h+1 else: print h, "is a factor" factors.append(h) h=h+1 if h <= n: b = factors [0:] + factors [:40] c = factors [0:] * factors [:40] if b==n: print n, "is not a perfect number" else: print "halfway there" if c==n: print n, "is not a perfect number" else: print n, "is a perfect number"
but i get the error
Traceback (most recent call last):
File "C:\Python25\perfect nums.py", line 22, in <module>
c = factors [0:] * factors [:40]
TypeError: can't multiply sequence by non-int of type 'list'
can you help please?
thanks in advance