I want to make a program which will return a nth number of digits after decimal in PI number. It works good as long as I don't put n higher than 50. Can I fix it or Python don't allow that?
Here's my code:
pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270938521105559644622948954930381964428
def nth_pi_digit(n=input("How many digits after decimal you would like to see?(PI number): ")):
try:
n = int(n)
if n <= 204:
return print(format(pi, f".{n}f"))
else:
print("Sorry, we have pi with 204 digits after decimal, so we'll print that")
return print(format(pi, ".204f"))
except:
print("You need to put a integer digit")
nth_pi_digit()