[Tutor] A dictionary question

Mark Lawrence breamoreboy at gmail.com
Fri Nov 19 07:29:13 EST 2021


On 19/11/2021 05:00, Phil wrote:

[big snip]

> for r in range(9):
>      for i in range(1, 10):
>          if i in row[r] and len(row[r]) > 2:
>              number_list.append(i)
>              row_list.append(r)
> 
> for i in range(len(number_list)):
>      print(number_list[i], end=' ')
> 
> print()
> 
> for i in range(len(row_list)):
>      print(row_list[i], end=' ')
> 

Besides the difficulties of understanding what you actually want, as has 
been raised elsewhere, please start writing standard Python for loops, 
e.g. :-

for row in row_list:
     print(row, end=' ')

If you need the index use 
https://docs.python.org/3/library/functions.html#enumerate

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list