Can’t use /= on numpy array
As pointed out in the comment, the change from int (which is how a is created) to float (which is the result of /) is not allowed when using /=. To “fix” this the dtype of a just has to be a float from the beginning: a=np.array([2, 4, 6], dtype=np.float64) a/=2 print(str(a)) >>>array([1., 2., 3.])