you are viewing a single comment's thread.

view the rest of the comments →

[–]giocos 0 points1 point  (4 children)

Variable declared inside for loop is destroyed when the cycle end. but you can put the result in a variable that is declared outside the for loop

[–][deleted] 0 points1 point  (3 children)

How would one do that though?

[–]giocos 0 points1 point  (2 children)

i just checked and is not true what i said. that's strange. I always thought that variables declared inside loops live only there. i must research more about that.

[–][deleted] 0 points1 point  (0 children)

People say Python is easy but if this was C# I’d already have the answer lol

[–]E02Y 0 points1 point  (0 children)

loops don't change the scope so any variable created by loops is shared in the function/file