Help with test 3 in prob_calculator.py

Hi,

I need some help to understand why my app is failing. Not an expert on random.
I’m getting very different results from my computer to rpl.it.
My comp is always around 0.27 and rpl.it is 0.17. but I have no idea how to improve those results.

This is my code:>

def draw(self, numero):
    cantidad = self.bolasTotales - numero
    if (cantidad < 0):
        return self.contents
    bolas = []
    for i in range(numero):
        indice = random.randint(0, len(self.contents)-1)
        bola = self.contents.pop(indice)
        bolas.append(bola)
    return bolas

Full code>
https://repl.it/join/hhgidbla-robertogimenez

Ideas welcome.

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0.

Challenge: Probability Calculator

Link to the challenge:

If I run your code the only failure is that you return a string instead of a number.
Changing that passes all the tests without issue.

1 Like

I can’t believe was that. Thanks!! :star_struck: