Issue with Second Test on Probability Calculator

Hi all, I am trying to finish up the probability calculator and feel like I’m just banging my head against the wall. The issue is with ‘test_hat_draw()’. I am not sure how I am failing this. The prompt says that it expects two random contents, which I am relatively certain my function returns, but my code continues to fail.

Here’s the link to my code:https://replit.com/@UlmoME/boilerplate-probability-calculator-1#prob_calculator.py

Here’s the link again if you can’t see it: https://replit.com/@UlmoME/boilerplate-probability-calculator-1#prob_calculator.py

The test just wants the output in a different order. Instead of appending, use a different array method to change the order and the output will be happy.

1 Like

This line:

                ball = random.choice(range(0, len(self.contents) - 1))

does not choose from every ball in self.contents. Python’s range() does not include the last number in the range.

2 Likes

I tried this and failed 3 tests instead of one. They assume the append order.

Without your specific code, I’m not sure what and how you are appending.
My solution doesn’t use append in the way that OP did at the time the code was originally posted.

Ah, yes - specifically, OP was appending the entire set of balls in the original order when asked to draw more than the hat contains, which was giving misordered results at that time.

Like I said, I have no way of guessing what is wrong with your code without seeing it. Usually, trolling old posts where the OP got the same error message is less successful for these particular projects since there are so many ways to be a bit off. You are better off making a new post.