I ask the user in my program to enter up to four types of income, with 0 filling the unused income slots. Then, the program is supposed to add up the incomes. It goes like this:
user defines values for incomes 1, 2, 3 and 4.
Program adds together the values of incomes 1, 2, 3 and 4.
Then it prints the calculation result to the screen.
Instead, it just repeats the variable that the user sets for incomes 1, 2, 3 and 4, and prints them in a long string, so if the values were each set to 500, it would print:
500500500500.
What am I doing wrong?
Here is the source code:
def clear():
print """
"""
def Main():
x = raw_input("# ")
if x == "calc" or x == "calculate":
calculate()
elif x == "convert":
clear()
print "Convert not implemented yet."
def calculate():
x = raw_input("Choose calculation type: ")
if x == 'money':
money_calc()
elif x == 'budget':
budget_calc()
elif x == 'grades':
grades_calc()
else:
clear()
print """Your only options within the calculate function are:
'money' , 'grades', and 'budget'.
"""
calculate()
def money_calc():
clear()
print """Choose your calculation type:
a. adding income b. adding expenses c. calculate total left over income after expenses
"""
x = raw_input("Please choose a, b, or c: ")
if x == 'a' or x == 'a.':
clear()
add_income()
elif x == 'b' or x == 'b.':
clear()
add_expenses()
elif x == 'c' or x == 'c.':
clear()
total_after_expenses()
else:
clear()
print "You must choose one of the following:"
money_calc()
def add_income():
clear()
x0 = raw_input("Enter Income 1: ")
x1 = raw_input("Enter income 2: ")
x2 = raw_input("Enter Income 3: ")
x3 = raw_input("Enter Income 4: ")
print "We will now calculate your total income amount."
calc = [x0 + x1 + x2 + x3]
print calc
x = raw_input("Press enter to go main prompt menu... ")
if x == "":
clear()
Main()
else:
clear()
Main()
Main()