Feb-02-2019, 04:30 AM
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.
Let's forget about all. You have the right idea, but you don't want to return True until the end of the loop. You are returning True when you get one correct result, you only want to do that when all the results are True. However, as soon as one of the checks fails (
So switch the conditional in the loop to return False if the element isn't correct. Then after both loops are done, return True.
Note that your code checks that all the items are 'X'. To check that they are all equal (no matter what they are), check against matrix[0][0] instead (that's the first item in the first row).
Let's forget about all. You have the right idea, but you don't want to return True until the end of the loop. You are returning True when you get one correct result, you only want to do that when all the results are True. However, as soon as one of the checks fails (
if element != 'X':
) you can return False. So switch the conditional in the loop to return False if the element isn't correct. Then after both loops are done, return True.
Note that your code checks that all the items are 'X'. To check that they are all equal (no matter what they are), check against matrix[0][0] instead (that's the first item in the first row).
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