Tell us what’s happening:
While calculating the probability for project no. 5 of Scientific Computing with Python, I am not able to get the expected probability. The delta is always 0.2.

For a start, if you got 1000 experiments, you definitly need to find a better way to check the results than printing about 7000 lines of text…

Because you obviously don’t actually know what to do with the printed lines to find your mistake anyway ^^°

That being said, the mistake is quite simple: You check if the “expected balls” are EXACTLY present. But the test only wants AT LEAST those numbers.
Example: 2 blue and 1 green expected → 2 blue and 2 green is also a favourable outcome. Your test however does not count that.

When you got 3 expected balls but draw 4 - you obviously cannot expect to get an EXACT match. You have to check if all 3 expected balls are there and it doesn’t matter what the 4th one is.