Why is the code not printing? NameError: global name 'input' is not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Logical21
    New Member
    • Nov 2015
    • 1

    Why is the code not printing? NameError: global name 'input' is not defined

    Code:
    def main():
      gross_income=int(input("Enter Gross Income"))
      tax_paid=float(input("Enter Tax Paid"))
      number_dependents=int(input("Number of Dependents"))
      cost_dependent=number_dependents*750
      income=gross_income-cost_dependent
      taxnet_income=income*0.05
      total_tax=cost_dependent+taxnet_income 
      taxDue(tax_paid,total_tax)
    def taxDue(paid,actual):
      refund=paid-actual
      owe=actual-paid
      if paid > actual:
        print("Expected refund in the amount of",refund)
      else:
        if paid < actual:
          print ("Send check for the amount",owe)
    main()
  • ManojS11
    New Member
    • Nov 2015
    • 1

    #2
    you should use python's raw_input() instead of input() like this -

    Code:
    def main():
      gross_income=int(raw_input("Enter Gross&n
    bsp;Income"))
    
      tax_paid=float(raw_input("Enter Tax 
    Paid"))
    
      number_dependents=int(raw_input("Number o
    f Dependents"))
    
      cost_dependent=number_dependents*750
      income=gross_income-cost_dependent
      taxnet_income=income*0.05
      total_tax=cost_dependent+taxnet_income&nbs
    p;
    
      taxDue(tax_paid,total_tax)
    def taxDue(paid,actual):
      refund=paid-actual
      owe=actual-paid
      if paid > actual:
        print("Expected refund&nb
    sp;in the amount of",refund)
    
      else:
        if paid < ac
    tual:
    
          print ("Send&
    nbsp;check for the amount",owe)
    
    main()

    Comment

    Working...