Checking specific list entry and the rest of the list entries

Im making a sudoku game and I need to be able to check if the entered number is already in the row or already in the column for a conflict. Right now this is changing the background of all of the seed values. How do I check for a specific entry and see if it is in either the row or the columns already?

  #nums_list is a 2_d list of the Entry widget id tags
  #check_list are the 0's and digits of the seed values
  def check_conf(self):
    for r in range(0, self.height, 1):
        for c in range(0, self.width, 1):
            if self.nums_list[r][c].get().isdigit():
                if int(self.nums_list[r][c].get()) == int(self.check_list[r][c]):
                    self.nums_list[r][c].config(background = 'red')

full code at http://pastebin.com/Mmmh6JM4

Answers


Glad you figured it out.

I'll risk downvotes for this comment in an answer: You could make your code a bit more readable if you did something like this:

#nums_list is a 2_d list of the Entry widget id tags
#check_list are the 0's and digits of the seed values
def check_conf(self):
    # iterate over rows
    for widgets, check_values in zip(self.nums_list, self.check_list):
        #iterate over columns
        for widget, check_value in zip(widgets, check_values):
            if widget.get().isdigit():
                if widget.get() == check_value:
                    widget.config(background = 'red')

Need Your Help

Memory warning when loading google map in UIWebView

objective-c ios4 uiwebview

In my app UIWebView loads Google maps, while using this

IF else statement in Linq

c# .net database linq

I have a datatable which contains following data as

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.