0

Working on an assignment for my intro level computer programming class. Tasked with making a dice game similar to Yahtzee. Below is the scoring to the game and when running, it never gets past the first 'if' statement?

dice_counter is a list indexed from 0-6 and storing the values of the rolled dice.

   if (2 and 1) in dice_counter:
        print('Two pair +5pts')

    elif (3 and 1) in dice_counter:
        print('Three of a kind +10pts')

    elif (3 and 2) in dice_counter:
        print('Full house +15pts')

    elif (4 and 1) in dice_counter:
        print('Four of a kind +20pts')

    elif dice_counter == [0,0,1,1,1,1,1] or [0,1,1,1,1,1,0]:
        print('Straight +20pts')

    elif 5 in dice_counter:
        print('Five of a kind +30pts')

    else: break
  • 2
    `2 and 1` evaluates to `2`... – jonrsharpe Sep 11 '16 at 19:33
  • I guess I am still thinking about in "english." @jonrsharpe can you explain to me why (2 and 1) evaluates to two? Even when the list doesn't hold a value of 2, it is still saying that condition is true? – A. Johnson Sep 11 '16 at 22:16
  • See e.g. http://stackoverflow.com/q/4477850/3001761. `2 and 1` returns `1`; I was incorrect about which value above, sorry about that. – jonrsharpe Sep 12 '16 at 06:22

0 Answers0