Extract data out of a Loop Using Lists
Variables within a loop cannot be directly referenced outside of loop. As such, users have to create lists to extract values from the last iteration or each iteration of a loop.
Extracting Values of the Last Iteration
To extract the last iteration of a For/While loop i.e. total_apple, create an empty list of the same variable name i.e. total_apple = [], outside and upstream of the loop. Placing the same variable name downstream and out of the loop will successfully acquire the last iteration of the loop.
Extracting Values From Each Iteration
To extract the value of total_apple from each iteration of a For/While loop, create an empty list upstream and outside of the loop and insert the function list.Add into the loop. This will add the value of total_apple in each iteration into the upstream list.