title: I have been trying to create a simple atm program, I am lost
body: <p>I need help with an ATM python program that I am creating. I am new to Python and I am worried that my coding is so off that I must start from the beginning. I am trying to separate the sections by <code>def ():</code> and I keep getting an error.</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/Users/tonystrobach/Desktop/untitled3.py&quot;, line 44, in &lt;module&gt;
      deposit()
    File &quot;/Users/tonystrobach/Desktop/untitled3.py&quot;, line 35, in deposit
      if (answer == &quot;D&quot;) or (answer == &quot;d&quot;):
  NameError: global name 'answer' is not defined
  </code></pre>
  <p>I have been searching a long time and trying to grasp the concepts of Python the best I can. Any suggestions would be helpful.</p>
  <p>Here is my code:</p>
  <h1>The purpose of this program is to create a simple ATM environment</h1>
  <h1>Written by K. Strobach 11/22/13</h1>
  <pre><code>def account():
      print (&quot;Hello, welcome to Bank of Python!&quot;)
      print (&quot;Please enter your account pin number&quot;)
      account = raw_input(&quot;Account pin number is 1234: &quot;)
      account = (1234)
  
  account()
  
  def balance():
      print (&quot;would you like to see your account balance?&quot;)
      see = raw_input(&quot;Enter Y or N: &quot;)
      if (see == &quot;Y&quot;) or (see == &quot;y&quot;):
          balance = int(0)
      print (&quot;Current balance: $&quot; + str(balance))
  
  balance()
  
  def transaction():
      print (&quot;Would you like to make a transaction?&quot;)
      more = raw_input(&quot;Enter Y or N: &quot;)
  
      if (more == &quot;Y&quot;) or (more == &quot;y&quot;):
          print (&quot;Would you like to make a deposit or withdraw? Or would you like to end this transaction?&quot;)
      answer = raw_input(&quot;Enter D for deposit; W for withdraw; E for end: &quot;)
  
  transaction()
  
  def deposit():
      if (answer == &quot;D&quot;) or (answer == &quot;d&quot;):
          print (&quot;How much would you like to deposit?&quot;)
          deposit = input(&quot;Enter amount to deposit: &quot;)
          deposit = int(deposit)
  
          currentbalance = deposit + balance
          print (&quot;Deposited: $&quot; + str(deposit))
          print (&quot;Current Balance: $&quot; + str(currentbalance))
  
  deposit()
  
  def withdraw():    
      if (answer == &quot;W&quot;) or (answer == &quot;w&quot;):
          print (&quot;How much would you like to withdrawl?&quot;)
          withdraw = input(&quot;Enter amount to withdraw: &quot;)
          withdraw = int(withdraw)
  
          currentbalance = withdraw - balance
          print (&quot;Withdrew: $&quot; + str(withdraw))
          print (&quot;Current Balance: $&quot; + str(currentbalance))
  
  withdraw()        
  
  def end():
      if (answer == &quot;E&quot;) or (answer == &quot;e&quot;):
          exit (&quot;Thank you for Banking with Bank of Python, goodbye!&quot;)
  
      else:
          exit (&quot;Thank you for Banking with Bank of Python, goodbye!&quot;)
  
  end()
  </code></pre>
  <p>This is for a class, but I am not worried about that, I just want to get a better understanding of how to make this work.</p>
  <p>Thanks in advance.</p>