This is my code and I want to save the output of this program into the text file.

```
#Compound Interest Calculation
#The formula for annual compound interest, including principal sum, is:
"""A = P*(1 + r/n)**(nt)
Where:
A = the future value of the investment/loan, including interest
P = the principal investment amount (the initial deposit or loan amount)
r = the annual interest rate (decimal)
n = the number of times that interest is compounded per year
t = the number of years the money is invested or borrowed for"""

# File Objects
with open('py.data.txt','w') as file: #in write mode
    file.write(str(cName))

cName = int(input("Enter the customer name:"))
print("The cutomer name is" , cName)
date_entry =  int(input("Enter a date in YYYY-MM-DD format:"))
print("The investment date is" , date_entry)
P = float(input("Please enter the amount you would like to invest:"))
print("The interest rate varies with the number of years")
t = float(input("please enter the number of years the money is inested or borrowed for:"))
print("The interest rate varies with the number of years")
if (t>=10):
    r = 0.05
    print("interest rate=0.05")
elif (t>=5):
    r = 0.03
    print("interest rate=0.03")
else:
    r = 0.02
    print("interest rate=0.02")

n = float(input("Please enter the number of times that interest is compounded per year:"))
A = P*(1 + r/n)**(n*t)
print("The value of investment is £" , A)

```