dimanche 28 avril 2019

How to get a specific number from a list?

I want to randomize the words in the list and if the randomized word equals to scissor I want the game to tell me that I've won but I cant find the solution, could you tell me where I done wrong?

I have tried "if 3 in my_list:" but still can't find the solution

import random

my_list = ["rock", "paper", "scissor"]
random.choice(my_list)
print(random.choice(my_list))

if random.choice(my_list) == my_list[3]:
    print("You Won!")
else:
    print("You Lost!")

I want to print "You Won" when the random.choice is scissors in the list.




Aucun commentaire:

Enregistrer un commentaire