I am trying to run the code presented on the second page:
At the bottom of the code you have to add these lines:
simFlips(100,100)
show()
Here is the error that I get when I run it on ubuntu:
Traceback (most recent call last):
File "coin.py", line 36, in <module>
simFlips(100,100)
File "coin.py", line 16, in simFlips
diffs.append(abs(heads - tails))
AttributeError: 'numpy.ndarray' object has no attribute 'append'
Please tell me what I'm doing wrong that gives me the last error. Thanks in advance!
diffs
variable is a numpy ndarray. Are you sure you left the line that saysdiffs = []
? This sets diffs to be an empty python list, which you can callappend
on. – jozzas Dec 7 '11 at 2:06