I am trying to access the coefficients after each atom in the unit cell formula, for example in the following unit cell, {“Li”: 4, “O”: 2}, i need to be able to access the numbers 4 and 2.
What I’m actually trying to do is calculate the mean atomic number per atom in a given unit cell for each of the entries i queried so i can later plot and analyze my data.
My thought process till this point is accessing each coefficient and atom, in each unit cell formula, in each entry, then calculate the mean atomic number and divide by the number of elements in each unit cell.
Is there by any chance a fastest way to achieve this with another (maybe single) command?
Hope i made myself clear enough

I assume you queried the MP API for either unit_cell_formula or reduced_cell_formula, right? In that case you already get the unit cell formula information as a Python dictionary which makes it pretty straight-forward to determine the mean atomic number:

it kinda is yes but what i had in mind, for example in the above scenario with Li and O, was:

mean atomic number = (4 * Z_Li + 2 * Z_O) / ( nsites ).

What i failed to understand at the time was dictionary structures, which i then researched a bit a got the right commands. A for loop with x, y in the dictionary allowed me to access those coefficients (values) and keys. Then with element().atomic_number from the mendeleev library i managed to calculate the appropriate the mean atomic number.