Apr-24-2019, 12:16 PM
(Apr-24-2019, 01:52 AM)Escribblings Wrote: As for what you say about the 25, the thing is that send to be working. It's the lines if x == 50: that seem to be being ignored.
It is not working. Test it yourself:
if (25 and 20 and 15) != 25: print("It's broken") else: print("It works")The and of two non-zero numbers is the number on the right. So as long as the last number is 25, and the first two numbers are non-zero (guaranteed since you're adding two numbers from 1 to 24), that will be true.
I gave you the correct format:
if 25 not in (corner2[0] + corner2[1], corner2[0] + corner2[2], corner2[1] + corner2[2]):
. In the above example, this would simplify to if 25 not in (15, 20, 25):
which would be False, since 25 is in the tuple. The easiest thing to do is just combine them with and's: if a + b != 25 and a + c != 25 and a + d != 25:
.Your all version does not work because it evaluates the all first. All of those sums are non-zero integers, which evaluate to True. So they are all True, and the all version simplifies to
if True != 25:
, which is always true.In terms of converting to functions, start with checking things. Make a function that returns True if a side is valid and False if it isn't. Do the same for a corner, and so on.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures