lundi 9 septembre 2019

Including more than 1 randomly generated item in if statement

I'm making a 'slot machine' code and am not able to use more than 1 of the items in the list in an if statement so I can then set separate statements for different item combinations.

Tried using if "item1" and "item2" in rand_items: or if "item1" and "item1" in rand_items: but it only really picks up one of them

items = ["diamond", "bomb", "apple"]
rand_items = (random.choices(items, k=3))
            print (rand_items)
            if "bomb" in rand_items:
                print ("Game over.")
                break
            elif "bomb" and "diamond" in rand_items:
                print("You may spin again.")
            elif "diamond" and "diamond" in rand_items:
                print("You won £25.")

It should take the two items and if it's a diamond AND bomb, continue or if there's two (more than 1) diamonds 'give' money.




Aucun commentaire:

Enregistrer un commentaire