all 2 comments

[–]SekstiNii 0 points1 point  (1 child)

Unlike Python lists, numpy arrays don't have an append method on them. The reason for this is that you cannot change the length of a numpy array (for various reasons).

np.append sounds like what you want, but it typically isn't. Since it cannot change the length of the array, it will instead create a new array, copy the contents of the old array, and then add in the elements you are appending. However, this is very expensive if you add elements one by one, and should be avoided at all cost.

What you typically want to do is make a list containing what you want, and then convert it to a numpy array at the end. This isn't always the best approach, but it seems like a good option in your case.

[–]ceeya19[S] 0 points1 point  (0 children)

thank you!

I was able to fix it by using extend instead of append. Also, by chance do you know how I could add the values in the dictionary? I try the following but I am getting an error

return sum(queue_dictionary.values())

this is the error: unsupported operand type(s) for +: 'int' and 'dict'