By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

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

P: 1
Expand|Select|Wrap|Line Numbers
  1. def main():
  2.   gross_income=int(input("Enter Gross Income"))
  3.   tax_paid=float(input("Enter Tax Paid"))
  4.   number_dependents=int(input("Number of Dependents"))
  5.   cost_dependent=number_dependents*750
  6.   income=gross_income-cost_dependent
  7.   taxnet_income=income*0.05
  8.   total_tax=cost_dependent+taxnet_income 
  9.   taxDue(tax_paid,total_tax)
  10. def taxDue(paid,actual):
  11.   refund=paid-actual
  12.   owe=actual-paid
  13.   if paid > actual:
  14.     print("Expected refund in the amount of",refund)
  15.   else:
  16.     if paid < actual:
  17.       print ("Send check for the amount",owe)
  18. main()
Nov 18 '15 #1
Share this Question
Share on Google+
1 Reply


P: 1
you should use python's raw_input() instead of input() like this -

Expand|Select|Wrap|Line Numbers
  1. def main():
  2.   gross_income=int(raw_input("Enter Gross&n
  3. bsp;Income"))
  4.  
  5.   tax_paid=float(raw_input("Enter Tax 
  6. Paid"))
  7.  
  8.   number_dependents=int(raw_input("Number o
  9. f Dependents"))
  10.  
  11.   cost_dependent=number_dependents*750
  12.   income=gross_income-cost_dependent
  13.   taxnet_income=income*0.05
  14.   total_tax=cost_dependent+taxnet_income&nbs
  15. p;
  16.  
  17.   taxDue(tax_paid,total_tax)
  18. def taxDue(paid,actual):
  19.   refund=paid-actual
  20.   owe=actual-paid
  21.   if paid > actual:
  22.     print("Expected refund&nb
  23. sp;in the amount of",refund)
  24.  
  25.   else:
  26.     if paid < ac
  27. tual:
  28.  
  29.       print ("Send&
  30. nbsp;check for the amount",owe)
  31.  
  32. main()
Nov 23 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.