-2

pick = 4 and 6 and 12 thanks

import random 
print("Are you feeling lucky today?")
loop='y'
while loop=='y':
    pick=int(input("Select your dice(4,6,12) then press enter:"))
    if pick in [4,6,12]:
         print("The "+str(pick) +" sided dice was thrown and your score is "+str(random.randint(1,pick)))
else:
    print("Invalid number. You are meant to select a 4, 6 or 12 sided dice!")
loop=input('Dare to go again?(y/n)?')
if loop=='n':
    print("Thanks for playing!")

input("Press enter to quit:")

  • 1
    possible duplicate of [Elif and if not working or me not understanding](http://stackoverflow.com/questions/14636446/elif-and-if-not-working-or-me-not-understanding) – Rohit Jain Oct 10 '13 at 15:03
  • What i'm trying to say is that pick=4 and 6 and 12 when run only works with 4 i wan't it to work with 6 and 12 as well – Marian Dumitriu Oct 10 '13 at 15:07

1 Answers1

4

Your condition is parsed as

(pick == 4) or (6) or (12)

which is always true because at least 1 of the three items (namely, 6 and 12) are true.

You want

if pick==4 or pick==6 or pick==12

or more simply

if pick in [4,6,12]
chepner
  • 497,756
  • 71
  • 530
  • 681