samedi 18 avril 2015

Python Input String If Equals

I am using Python 3.4.3 and trying to take user input and depending on what it is equal to, do a math operation. Here is my code:



def main():
print("---------- Loan Underwriting ----------")
income = input("Enter applicant income: ")
income = float(income)
type = input("Enter type (M [Monthly], B [Bi-weekly], or W [Weekly]): ")
type = type.upper()

if type == 'M':
max_payment = income // 4
if type == 'B':
max_payment = income // 2
if type == 'W':
max_payment = income
else:
max_payment = 0


print("Max payment: " + str(max_payment))


If you enter the income at 1000.00 and choose monthly, it should output 250.00 however, it outputs 0. Same thing for bi-weekly, but weekly does work. What am I doing wrong?


Thank you so much.


Aucun commentaire:

Enregistrer un commentaire