-1

I need some help regarding the random wire selector, what would be a good way to store/select the values?

import random

wires = ["yellow", "blue", "green"]
# need some help making this random wire selector
bomb = random wire
neutral = random wire
diffuse = random wire
# bomb, neutral, diffuse can't be equal
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
ben_g_123
  • 108
  • 5

1 Answers1

-1

For the wires

bomb = random.choice(wires)

Now you need to remove the element and random one of the other elements

wires.remove(bomb)
neutral = random.choice(wires)

And what's left is the third choice

diffuse = wires.remove(neutral)

There are if problems you need to always use ==

if input = diffuse (bad - this is an assignment not an equality)

For timing you need to use the time module https://docs.python.org/2/library/time.html sleep is not what you need here. Timestamp after the user answers Y and then timestamp and calculate the difference to know how much time has passed.

TigOldBitties
  • 1,331
  • 9
  • 15