How do you add one (+1) to a cell with an existing element in an numpy array? I have a 21x23 zeros array and I want to count occurences by adding one .
for r in holdscore:
results = np.zeros(shape=(21, 23))
if one_game(r) < 21:
results[r,one_game(r)] += 1
if one_game(r) > 21:
results[r, 22] += 1
numpy, but what you seem to be doing is that you are resettingresultsfor every iteration. Try putting it outside the loop.