This is only something small but, I think line 17 should read `while trials < cap:` rather than `while trials <= cap:` This can be seen by setting max to 0. There should only be 1 trial but there will be two 2 It is even less of an issue with larger values of max