in phi(n), "return amount" is indented improperly, making phi(n) = 1 for all n.
in step3(n,r) the range is set to (r,2) instead of (2,r). This means the required trial division does not happen.
In both step3 and step5 you need to make sure your range includes the value.
In step5, um, what? You're setting x to an integer value and then just doing a modular exponentiation. That isn't how it works.
in phi(n), "return amount" is indented improperly, making phi(n) = 1 for all n.
in step3(n,r) the range is set to (r,2) instead of (2,r). This means the required trial division does not happen.
In both step3 and step5 you need to make sure your range includes the value.
In step5, um, what? You're setting x to an integer value and then just doing a modular exponentiation. That isn't how it works.