I'm trying to get all the inputs added in a different function and then returned to main but I am getting the error: Can't convert 'int' object to str implicitly
.
Here's my code:
def main():
input1 = input("Enter the month: ")
input2 = input("Enter the year: ")
input3 = input("Enter the home mortgage payment amount: ")
input4 = input("Enter the car payment amount: ")
input5 = input("Enter the gas payment amount: ")
input6 = input("Enter the electric payment amount: ")
input7 = input("Enter the phone payment amount: ")
input8 = input("Enter the cell payment maount: ")
input9 = input("Enter the miscellaneous payment amount: ")
monpay = calcMonthlyPay(input3,input4,input5,input6,input7,input8,input9)
yearpay = calcYearlyPay(monpay)
print("SUCCESS: Data wrtten to the may.txt file")
file = open("may.txt", "w")
file.write(input1 + "\n" + input2 + "\n" + input3 + "\n" + input4 + "\n")
file.write(input5 + "\n" + input6 + "\n" + input7 + "\n" + input8 + "\n" + input9 + "\n")
file.write(monpay + "\n")
file.write(yearpay)
file.close()
def calcMonthlyPay(input3,input4,input5,input6,input7,input8,input9):
monthpay = (input3+input4+input5+input6+input7+input8+input9)
return monthpay
def calcYearlyPay(monpay):
yearpay = monpay * 12
return yearpay
main()