Python while loop

Python while loop

what each line of code in while loop do?can you please explain?


It will print reverse of an array.


You r trying to reverse ur array.
First of all, u check that ’ i ’ hasn’t come to the end of loop so u wouldn’t get any errors
Then u take ’ tmp ’ var as storage to ur [0] element of the array and on the second line u change ur [0] element to the last so ur array begins with number = 5. Then u remember about ’ tmp ’ var and give its value to the last element so it becomes = 1.
After all you just make a step forward( i+=1) and step backward(j = j - 1)