As explained in this link, floating point numbers are not stored perfectly in computers. You are most likely experiencing some error in calculation based off of this very small difference that persists in floating point calculations.
When I run your function, the equation ((x ** (1./float(z))) * 10 % 10)
results in 9.99999999999999986
, not 10
as is expected. This is due to the slight error involved in floating point arithmetic.
If you must calculate the value as a float (which may or may not be useful in your overall goal), you can define an accuracy range for your result. A simple check would look something like this:
precision = 1.e-6
check = (x ** (1./float(z))) * 10 % 10
if check == 0:
# No changes to previous code
elif 10 - check < precision:
c.append(int(x**(1./float(z))) + 1)
c.append(z)
precision
is defined in scientific notation, being equal to 1 x 10^(-6)
or 0.000001
, but it can be decreased in magnitude if this large range of precision introduces other errors, which is not likely but entirely possible. I added 1
to the result since the original number was less than the target.