[Tutor] function return values

Alan Gauld alan.gauld at yahoo.co.uk
Thu Dec 2 13:37:47 EST 2021


On 02/12/2021 00:24, Phil wrote:

>      def boxPairsInSameRow(self, pairs, x, y):
>          col_list = []

You don't need this since you set it below

> 
>          for item, count in pairs.items():
>              if count == 2:  # then item is a pair candidate
>                  for row in range(x, x + 3):
>                      col_list = []
>                      for col in range(y, y + 3):
>                          if item in self.solution[row][col]:
>                              col_list.append(col)
>                      return item, row, col_list

This return will happen after the first row is processed,
you never process the other rows. I suspect that's not
what you intended?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list