I was trying to figure out how to populate an array with zeros and came across this solution that confused me.
col = 3
row = 3
A = [[0 for column in range(col)] for row in range(row)]
How come you can put a number next to a for loop and python will know to repeat that value within it? If I do:
0 for column in range(col)
outside of the list it comes out as an error. Why is this?
Also how does adding a for loop work here? I thought the for loop format was like this:
for value in Something:
#Repeating code
Why doesn't the solution follow this for loop format? If I did a for loop not in this format outside the list it comes out as an error.