Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparisons with functions
#1
If I have a function with some values that I defined in the function, how would i go about getting those values out to be check against.
I know I can return values, just not sure with this setup.
Any guidance much appreciated.

Some other stuff above

check = ['x','x','x']

for value in self.possible():
    if check in value:
        do stuff

def possible(self):
        # Rows
        self.row1 = [self.grid[0], self.grid[1], self.grid[2]]
        self.row2 = [self.grid[3], self.grid[4], self.grid[5]]
        self.row3 = [self.grid[6], self.grid[7], self.grid[8]]

        # Columns
        self.col1 = [self.grid[0], self.grid[3], self.grid[6]]
        self.col2 = [self.grid[1], self.grid[4], self.grid[7]]
        self.col3 = [self.grid[2], self.grid[5], self.grid[8]]

        # Diagonals
        self.diag1 = [self.grid[0], self.grid[4], self.grid[8]]
        self.diag2 = [self.grid[2], self.grid[4], self.grid[6]]

I figured it out. I made a list with the values and returned them. I must be getting tired.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#2
If it is solved, you can mark the thread as solved!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with readlines() and comparisons dudewhoneedshelp 2 2,180 Jul-23-2020, 10:21 AM
Last Post: DeaD_EyE
  List Comparisons and Deleting Valuebles KaleBosRatjes 4 3,718 May-13-2018, 02:14 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

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