title: python NameError: name 'ftax' is not defined
body: <p>I've been reading on your site for a couple of days and trying to debug my first python program that calculates the retail price + taxes and gives you the final price. </p>
  
  <p>this is the error I get when I run it on python IDLE 3.4.2 on mac:</p>
  
  <pre><code>Enter the retail price $200
  Traceback (most recent call last):
    File "/usr/local/bin/sale tax.py", line 36, in &lt;module&gt;
      total = calc_total(retailprice, ptax, ftax)
  NameError: name 'ftax' is not defined
  </code></pre>
  
  <p>As suggested in other posts, I try to define ftax as a global variable outside main() and then calling it in the function but it doesn't work. </p>
  
  <p>Below is my code as per the error message without global variable:</p>
  
  <pre><code>def main():
      print ('The sale tax calculator program')
      print
  
  def input_retail():
      retailprice = input('Enter the retail price $')
      retailprice = float(retailprice)
      return retailprice
  
  def calc_ptax(retailprice):
      ptax= retailprice * 0.099
      return ptax
  
  def calc_ftax(retailprice):
      ftax = retailprice * 0.05
      return ftax
  
  def calc_total(retailprice,ptax,ftax):
      total = retailprice + ptax + ftax
      return total
  
  retailprice = input_retail()
  ptax = calc_ptax(retailprice)
  tax = calc_ftax(retailprice)
  total = calc_total(retailprice, ptax, ftax)
  
  def print_info(retailprice,ptax,ftax,total):
  
      print( 'The retailprice is $' , retailprice)
      print ('The QST amount is $' , ptax)
      print ('The GST amount is $', ftax)
      print ('The total amount is $', total)
  
  print_info(retailprice, ptax, ftax, total)
  
  main()
  </code></pre>