1
I am trying to make a program that simulates the game "Door of Hope" of Silvio Santos in Pyton and I need the program to generate a random number, excluding the number previously generated. I did it that way:
premio = rd.randint(1,3)
p = int(premio)
print(p)
w = rd.sample(range(1,3), p)
print(w)
But a warning appears saying that the sample is larger than the population. I do not know how else to do!
p.s.: for those who want to help the program as a whole, here is the question:
Make a program that simulates the behavior of Silvio Santos. Your program must:
- randomly choose one of the three doors and place the prize behind it (do not tell the user where the prize is);
- ask for the user chooses one of the three ports; open a port that does not have the prize and that the user has not chosen (if there is more than one choice for the port to be open, your program should open any of them with equal probability);
- show user which port was opened;
- ask the user if he wants to keep his initial choice or if he wants to change port;
- show the user whether or not he has won the prize.
Make a Fisher-Yates: https://answall.com/search?q=fisher+yates
– Maniero
This problem must be occurring because 'p' must have received value 3, but range(1,3) generates a list of 2 numbers: [1, 2]. The correct would be range(1.4)
– Fabiano