mercredi 3 octobre 2018

Not sure how to enable this if and else statement to reveal the correct string

When I run this bit of code here, the resulting string is random, and doesn't adhere to the rules I laid out for it. Is there a better way to format this statement for it to run properly?

import random
for x in range(1):
  print random.randint(1,8)

if random.randint(1,8) in {1, 2, 3}:
  print("https://media.giphy.com/media/vgPDmpQsQsjug/giphy.gif")

elif random.randint(1,8) in {4, 5, 6}:
  print("http://i0.kym-cdn.com/photos/images/original/000/676/205/57b.gif")

else:
  print("Bye")

Aucun commentaire:

Enregistrer un commentaire