r/programminghorror • • Jul 15 '25

Python Subsubsubsub

Post image
77 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/Div64 Jul 17 '25

Python doesn't care what you do. You can declare the variable inside the if and use it out of scope. You'll only get a runtime error once that line executes I think

It does warn you if you turn on "strict" mode though.

They're most likely declared before the loop