-3

So the 'player' has to enter a number either 1 or 2. I need to use Python to make it so it will randomly choose a number so one will be 'good' and the player lives and the other 'bad' so the player dies.

3 Answers3

0
import random

c = random.choice([1, 2])

or

c = random.randrange(1, 3)
Lee Daniel Crocker
  • 12,927
  • 3
  • 29
  • 55
0

This is something that you could have Googled or consulted the documentation for... however, here's a basic implementation.

import random
x = random.randint(1, 2)
le_wofl
  • 304
  • 3
  • 15
0
import random
variable_name = random.randint(x, y)
# x is the min and y is the max
Trolmaso
  • 1
  • 3