0

Here is the code I have so far:

import random
a = ["blue","red","green","yellow"]
b = random.randint(1,100)
c = "The light is"
if 1 <= b < 5:
    print(c, a[0])
if 5 <= b < 80:
    print(c, a[1])
if 80 <= b < 90:
    print(c, a[2])
if 90 <= b <= 100:
    print(c, a[3])

It returns 4 possible different colors the light can be, but not all of them are equally probable. Do I really need to write out 4 separate if statements, or is there a simpler way of doing this?

Learner X
  • 1
  • 1

0 Answers0