Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matrix
#4
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 (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
Reply


Messages In This Thread
Matrix - by Helmi - Feb-02-2019, 03:02 AM
RE: Matrix - by ichabod801 - Feb-02-2019, 03:06 AM
RE: Matrix - by Helmi - Feb-02-2019, 03:34 AM
RE: Matrix - by ichabod801 - Feb-02-2019, 04:30 AM
RE: Matrix - by perfringo - Feb-02-2019, 04:58 AM
RE: Matrix - by perfringo - Feb-02-2019, 08:37 AM
RE: Matrix - by Helmi - Feb-02-2019, 01:02 PM
RE: Matrix - by ichabod801 - Feb-02-2019, 04:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Check if two matrix are equal and of not add the matrix to the list quest 3 984 Jul-10-2023, 02:41 AM
Last Post: deanhystad
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,523 May-03-2021, 06:30 AM
Last Post: Gribouillis
  matrix from matrix python numpy array shei7141 1 3,830 Jan-16-2017, 06:10 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020