Hi, I'm trying to get familiar with array. Right now, I've made something like a sodoku: Here's my code:
def Hi1(): a = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 1, 2, 3], [7, 8, 9, 1, 2, 3, 4, 5, 6], [2, 3, 1, 5, 6, 4, 8, 9, 7], [5, 6, 4, 8, 9, 7, 2, 3, 1],[8, 9, 7, 2, 3, 1, 5, 6, 4], [3, 1, 2, 6, 4, 5, 9, 7, 8], [6, 4, 5, 9, 7, 8, 3, 1, 2], [9, 7, 8, 3, 1, 2, 6, 4, 5]] for i in range(len(a)): for j in range(len(a[i])): print(a[i][j], end=' ') print()
Output:>>> Hi1()
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 1 5 6 4 8 9 7
5 6 4 8 9 7 2 3 1
8 9 7 2 3 1 5 6 4
3 1 2 6 4 5 9 7 8
6 4 5 9 7 8 3 1 2
9 7 8 3 1 2 6 4 5
The problem is that I don't know how to turn this code in a fonction which takes lists in argument(I want to enter the lists in the console, and then it gives me the sodoku). This is what I've made so far. Could you please fix my prblem? Thanks !def Hi2(a): a=[[],[],[],[],[],[],[],[]] for i in range(len(a)): for j in range(len(a[i])): print(a[i][j], end=' ') print()