Shawnphi
Shawnphi

Reputation: 35

Simple tax program with python

I'm having difficulty completing my income tax program for my class, mainly the output of the Social Security Number(SSN). I believe the rest of the code is correct based on the task I was given. I have the user input the SSN with hyphens, the program splits it so it can verify the number is a valid SSN, and then I want it to output the original SSN. Please let me know if I should make any other changes.

Original Task - Compute an income tax according to the rate schedule below:

Write a Python program to do the following:

Here is my code:

def main():
    name = input("Enter full name: ")
    ssn = input("Please enter social (###-##-####): ")
    income = eval(input("Please enter income: "))

    ssn = ssn.split("-")
    tax = 0.0

    if income >= 30000:
        tax = ((income - 30000) * .1) + (15000 * .05)
        income = income - tax
    elif income >= 15000:
        tax = (income - 15000) * .05
        income = income - tax
    elif income >= 0:
        income = income
    else:
        print("Please enter a valid income of more than $0!")

    if list(map(len,ssn)) != [3,2,4]: 
        print("Please enter a valid Social Security Number!")
    else:
        print("\nYour name:",name)
        print("Your SSN: ",ssn)
        print("Amount you will pay in tax: $",tax)
        print("Amount you will have after tax: $",income)

main()

Upvotes: 0

Views: 8435

Answers (1)

Abhishek Malik
Abhishek Malik

Reputation: 577

your ssn is now a list, to print the full ssn as normal use print("-".join(ssn))

Upvotes: 1

Related Questions