I am in the process of learning Python. I came across a review question and am having some trouble understanding the notation of how a variable is declared. Below is the variable:
t = [[3-i for i in range(3)] for j in range(3)]
I am familiar with the range function but am unsure with the above notation. My assumption of what is happening is the variable t
has a nested for loop. I am more familiar with the following notation:
for i in range(3):
for j in range(3):
# some code
but I am unsure how the first part of the variable 3-i
plays a factor in this. Any advice would be helpful.