I am trying to get a better understanding of a nested for loop in python:
nums = [2,4,6,8,10] for i in range(len(nums)): for j in range(i): print("i: " + str(i)) print("j: " + str(j))
i is starting at index 1 instead of index 0, but if I change the range of
for j in range(i) to anything other than the variable i, it starts at index 0.
If someone could quickly explain the functionality of this, it would be greatly appreciated.
range(i) is empty, so it skips the inner loop:
>>> list(range(0))