#This is an example to try and understand 2D lists

##Allocating element no.
i=2
j=3

##Defind a 2D list
numberGrid= [
[1,2,3],[4,5,6],[7,8,9],[0]
]
##Accessing (1+1)th row and (2+1)th col
print(" ")
print("Accessing " + str(i) + "th row and " + str(j) + "th col using numberGrid[" + str(i-1) + "][" + str(j-1) + "]")
print (numberGrid[i-1][j-1]) # no. starts form 0.

##We now want to use a nested for loop to access each element
print(" ")
print("Printing out each element using Method I")
for i in numberGrid:
    for j in range(len(i)):
        print(i[j])

#Alternatively
print(" ")
print("Printing out each element using Method II")
for i in numberGrid:
    for j in i:
        print(j)

##print each row
print(" ")
print("To show that the outer loop is over a 1D list")
for i in numberGrid:
    print(i)
