Nov-17-2019, 10:16 PM
Hi, I'm trying to get familiar with lists. Right now, I have a little Issue. I'm trying to convert this code (kind of sodoku) into a function, who takes in arguments lists . 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()And this is what I made, I can't understand how array works in python, Thank ya all !
def Hi2(a): a=[[],[],[],[],[],[],[],[]] for i in range(len(a)): for j in range(len(a[i])): print(a[i][j], end=' ') print()