I was surfing YouTube and found a random video of a python quiz. The question goes like this:
What will be the output of this python code:
a = []
for i in range(10):
a.append(i * ++i)
for a[i] in a:
print(a[i])
I paused the video, tried to figure out the output, but I couldn't, because python doesn't have any ++ operator. Then I continued the video and I understood the first for loop, but the second for loop is very tricky, as is mentioned in the video. The guy explained in the video what is happening in the second for loop, but the explanation was too brief for me to understand it clearly. I tried to run the code in VS code, trying print statements and other stuff but still no help.
So, can you please help me in understanding the second for loop, maybe a step-by-step explanation?
Here's the video link (Hindi language): https://youtu.be/HbjaAm4Bib0