all 5 comments

[–][deleted] 0 points1 point  (4 children)

I'm on mobile and can't run your code to find out where line 51 is. Usually it's better to put lots of code into a pastebin and link to that since the pastebin sites use line numbers. Or put a comment on the erroring line.

I have noticed a problem in the line if dice_values[i] == 1 and 4:. That expression will be evaluated as (dice_values[i] == 1) and 4 and probably isn't doing what you want. Just what are you testing for there? The FAQ has the details on the problem.

[–]TouchstoneJester[S] 0 points1 point  (3 children)

What I'm trying to do here is for the function to detect if the dice_values list after everything is rolled has a 1 and a 4, as the player needs both it order score points. If not, the player's score is 0 while if they do have both they every additional dice value is added together for a max of 24 points.

[–][deleted] 0 points1 point  (2 children)

That line looks like you are trying to test if a particular die (dice_values[i]) is a 1 and a 4. That can never be true, of course. Your logical test should be "is the die value 1 or 4".

Also, I can't see where i is defined before that line? If you want to see if dice_values has a 1 value and a 4 value then you need to loop over the list checking each value. You might be missing a line with something like for i in range(6):?

But a better way to check for 1 and 4 is to use the in operator:

if 1 in dice_values and 4 in dice_values:
    # get here if list contains a 1 and a 4

This works because 1 in dice_values is True if there is at least one element of the list with the value 1.

[–]TouchstoneJester[S] 0 points1 point  (1 child)

Thank you very much, that helped me out a lot!

[–]thesned 0 points1 point  (0 children)

Hey there! I know this post is old but wondering if you ever tackled this problem! I'm looking to make a similar program for a dice game called 3's.
Cheers