Depletion run problem with Materials class

Hi OpenMC community,

I’m very new to this software, but I am currently writing a project in which I am supposed to simulate a Molten Salt Reactor. The main goal of the project is to simulate the reactor and examining the build-up of Xe-135. To do this I have written a depletion code which, in theory, should simulate each individual time-step, extract the amount of Xenon and fuel, and resume the simulation with the given amounts.
I start by writing a function which defines my materials, but later on in a different function I wish to use these materials, but the code doesn’t recognize the local variables. So is there any way to “re-assign” the different materials from a global scope to local variables within the function?

Please excuse me if I am doing any formatting wrong in this post, I am quite new to this.
Any help is greatly appreciated!

(I have attached the “single-time-step-run” piece of code as a .png, materials is defined elsewhere in the code)

In Python, you can have a function or method modify a global variable (without introducing a new local variable name) by explicitly indicating that it is global, e.g:

x = 0

def func():
    # Modify the global copy of x
    global x
    x = 1

print(x)  # should print 1

Going the other way, the local variables (names) in a Python function cease to exist once the function returns, but the objects the names refer to still exist as long as there is some other name in scope that refers to them. If you want to modify the same object within a local and global scope, you should pass that object as an argument to the function and/or make it a return value.