So just as a starting point it may be helpful to have another function to handle calculations and a function to handle input and call the calculating function.
Not sure which variables you'd want to have but here:
Code:
def apr(principal, years, interest):
top = principal*interest;
bottom = 1 - (1+interest)**(-1*years);
return round(top/bottom, 2);
def main():
print apr(1000, 1, 0.06);
print apr(1000, 2, 0.06);
print apr(1000, 3, 0.06);
main();
This probably is incorrect, but it's helpful to show you a cleaner way to format your code to find issues much faster. And you can unit test easier.
If you want to test you can type 'python' import your code (if the filename is 'apr' then 'import apr' and test like so 'apr.apr(principal, years, interest)';
That should help you test faster.
Now you handle the input. Make sure you convert to int() or float() where appropriate.