Jun-09-2024, 07:50 PM
(This post was last modified: Jun-09-2024, 08:17 PM by deusablutum.)
On the program I'm currently working on I have a variable that disappears at an if statement and I can't figure out why. Here is sort of what the code looks like:
while (iteration_index < data_iterations): Do some stuff... for something in something_else: my_variable = something Do more stuff... print(my_variable) # variable still there for something_else_2 in more_things: filter_a_dataframe = an_unfiltered_dataframe print(my_variable) #still looks good if (not filter_a_dataframe.empty): print(my_variable) #my_variable has been erased here break else: continueOddly, if the if statement changes from
if (not filter_a_dataframe.empty)to
if (filter_a_dataframe.empty)the variable doesn't get erased. Any ideas why this is happening? Also, I can provide the specific code if that helps. I was just trying to simplify it for easy reading.