Ask coding questions

← Back to all posts
5
Monty Hall
ebest (407)

I'm trying to make the Monty Hall problem using python. Random does not seem to be so random. What's the problem?
https://repl.it/@ebest/Monty-hall
Ok, I think this works now. But I got 1 goat and 13 cars once?

Answered by Scoder12 (320) [earned 5 cycles]
View Answer
Commentshotnewtop
2
Scoder12 (320)

Random does not seem to be so random.

What do you mean by this? Can you be more specific? It seems to be random enough for me.

I am a repl.it helper. If this is a good answer, please upvote!

1
ebest (407)

@Scoder12 I tried it a few (30) times with changing on, but it gave 20 goats and 10 cars to me. I know the Monty Hall problem should output another result.
Also, I tried it with the code showing the doors, but it seemed randint was biased to the 1st and 3rd doors.

1
bearableschemer (2)

It's often tempting to blame a language or its libraries for a bug, but unexpected behavior is almost always the result of something you overlooked. Here, the trick behind the Monty Hall problem is that Monty knows what's behind each door and chooses to reveal a goat. I don't know what you're doing, but it isn't that.