title: How do I reset my calculator, when I enter "$" to input , instead of a number , python
body: <p>I need to reset this calculator when user enter &quot;$&quot; instead first or second input number or user enter &quot;<code>$</code>&quot; end of the input number (ex: <code>5$</code>,<code>20$</code>).</p>
  <p>the <code>(a,b)</code> is input number1 and number2. it was assigned as global varibles.</p>
  <p><code>select_op(choice)</code> is function, running the operation that user need. <code>input_function()</code> is function for input two numbers.</p>
  <pre><code># Functions for arithmetic operations.
  
  
  def add(a,b):
      return (a+b)        # 'a' and 'b' will add.
  
  def subtract(a,b):
      return (a-b)        # 'b' substract from 'a'.
  
  def multiply(a,b):
      return (a*b)        #'a' multiply by 'b'.
  
  def divide(a,b):
      if b == 0 :         .
          return None
      else:
          return (a/b)    # 'a' divided by 'b'.
  
  def power(a,b):
      return (a**b)       # 'a' power of 'b'.
  
  def remainder(a,b):
      if b == 0:           
          return None
      else:
          return (a%b)    # reminder of 'a' divided by 'b'.
  
  
  #this function for out put of operation
  
  def select_op(choice):      #this function will select operation
      if choice == &quot;+&quot;:
          input_function()
          print(a,' + ',b,' = ',add(a,b))
      elif choice == &quot;-&quot;:
          input_function()
          print(a,' - ',b,' = ',subtract(a,b))
      elif choice == &quot;*&quot;:
          input_function()
          print(a,' * ',b,' = ',multiply(a,b))
      elif choice == &quot;/&quot;:
          input_function()
          if b==0:                            
              print(&quot;float division by zero&quot;)
          print(a,' / ',b,' = ',divide(a,b))
      elif choice == &quot;^&quot;:
          input_function()
          print(a,' ^ ',b,' = ',power(a,b))
      elif choice == &quot;%&quot;:
          input_function()
          if b==0:                           
              print(&quot;float division by zero&quot;)
          print(a,' % ',b,' = ',remainder(a,b))
      elif choice == &quot;#&quot;:                    #if choice is '#' program will terminate.
          return -1
      elif choice == &quot;$&quot;:                    #if choice is '$' program reset.
          return None
      else:
          print(&quot;Unrecognized operation&quot;)
  
  
  
  #this function for input two operands.
  def input_function():
      number1=float(input(&quot;Enter first number: &quot;))
      number2=float(input(&quot;Enter second number: &quot;))
      global a,b
      a=number1
      b=number2
      return a,b
  
  
  #loop repeat until user need to terminate.
  
  
  while True:
    print(&quot;Select operation.&quot;)
    print(&quot;1.Add      : + &quot;)
    print(&quot;2.Subtract : - &quot;)
    print(&quot;3.Multiply : * &quot;)
    print(&quot;4.Divide   : / &quot;)
    print(&quot;5.Power    : ^ &quot;)
    print(&quot;6.Remainder: % &quot;)
    print(&quot;7.Terminate: # &quot;)
    print(&quot;8.Reset    : $ &quot;)
  
  
    # take input from the user
    choice = input(&quot;Enter choice(+,-,*,/,^,%,#,$): &quot;)
    print(choice)
  
  
    if(select_op(choice) == -1):
      #program ends here
      print(&quot;Done. Terminating&quot;)
      exit()
  </code></pre>