[Python] AttributeError: 'numpy.ndarray' object has no attribute 'append'

Discussão em 'Python' iniciado por Stack, Julho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to run the code presented on the second page:

    http://ocw.mit.edu/courses/electric...fall-2008/video-lectures/lecture-20/lec20.pdf

    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'


    What am I doing wrong that gives me the last error?

    Continue reading...

Compartilhe esta Página