Add an element to the list after x of N rounds

Let's say I have the following list in python:

probs = [0.1, 0.4, 0.9]

the number of experiments is 20 (N_episodes) and after x experiments, e.g. 10, I want to add an element to the list.

I already came up with a for loop:

for i in range(N_episodes):
        new_bandit = np.random.random()
        new_bandit_probs = probs.append(new_bandit)

but this gives me endless new elements, I just want one new element. Can someone help me out?

Read more here:

Content Attribution

This content was originally published by toni.jndr at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: