title: Easiest way to exit from menu
body: <p>I finished all my homework but i forgot to put a cancel option under submenu. I do not want to change all my files, it took 2 days to do this. What will the easiest way to add a cancel and return to main menu option on sub_menu.py</p>
  
  <p><strong>this is the sub_menu.py</strong></p>
  
  <pre><code>#!/usr/bin/python
  
  ## sub_menu.py
  
  #=========#=========#=========#=========#=========#=========#=========#
  def how_many():
      while True:
          print
          print "  How many do you want to draw? -----Range is from 1 to 5-----"
          shape_num = raw_input('  Enter your choice: ')
          try: 
              shape_num = int(shape_num)
              if (1 &lt;= shape_num &lt;= 5):
                  print "  Number ", shape_num ," is OK."
                  break
              else:
                  print
                  print "  The number you entered must be from 1 to 5 only."
          except:
              print
              print "  Only numbers allowed - Please try again"
      return shape_num
  
  
  
  #=========#=========#=========#=========#=========#=========#=========#
  def main():
      how_many()
  #=========#=========#=========#=========#=========#=========#=========#
  if __name__ == "__main__":
      main()
  
  #=========#=========#=========#=========#=========#=========#=========#
  </code></pre>
  
  <hr>
  
  <p><strong>this is the main one</strong></p>
  
  <hr>
  
  <pre><code>#!/usr/bin/python
  
  ## my_menu.py
  
  import sub_menu as s_m
  import draw_shape as d_s
  
  #=========#=========#=========#=========#=========#=========#=========#
  def main():
      while True:
          print
          print "  Draw a Shape"
          print "  ============"
          print
          print "  1 - Draw a triangle"
          print "  2 - Draw a square"
          print "  3 - Draw a rectangle"
          print "  4 - Draw a pentagon"
          print "  5 - Draw a hexagon"
          print "  6 - Draw an octagon"
          print "  7 - Draw a circle"
          print
          print "  X - Exit"
          print
  
          choice = raw_input('  Enter your choice: ')
  
          if (choice == 'x') or (choice == 'X'):
              break
  
          elif (choice &gt;= "1" and choice &lt;= "7"):
              my_shape_num = s_m.how_many()
              # draw in the middle of screen if == 1
              if (my_shape_num == 1):
                  d_s.start_point(0, 0)
              else:
                  d_s.start_point()
              #
              if choice == '1': 
                  d_s.draw_triangle(my_shape_num) 
              elif choice == '2': 
                  d_s.draw_square(my_shape_num) 
              elif choice == '3':             
                  d_s.draw_rectangle(my_shape_num) 
              elif choice == '4':             
                  d_s.draw_pentagon(my_shape_num) 
              elif choice == '5':             
                  d_s.draw_hexagon(my_shape_num) 
              elif choice == '6':             
                  d_s.draw_octagon(my_shape_num) 
              elif choice == '7': 
                  d_s.draw_circle(my_shape_num)
  
              d_s.t.end_fill() # shape fill color --draw_shape.py-- def start_point
  
          else:
              print
              print '  Try again'
              print
  
  
  #=========#=========#=========#=========#=========#=========#=========#
  
  if __name__ == "__main__":
      main()
  
  #=========#=========#=========#=========#=========#=========#=========#
  </code></pre>
  
  <hr>
  
  <p><strong>this is the drawshape one</strong></p>
  
  <hr>
  
  <pre><code>#!/usr/bin/python
  
  ## draw_shape.py
  
  import turtle as t
  
  #=========#=========#=========#=========#
  def start_point(x=-240, y=0):
      # Added 23 dec 11 baris
      t.color("black", "red")
      t.shapesize(outline=8)
      t.begin_fill()
      #
      t.penup() 
      t.setpos(x, y) 
      t.pendown()
  
  def spaces_after(x=120):
      t.penup() 
      t.forward(x)
      t.pendown()
  
  #=========#=========#=========#=========#
  def draw_triangle(num=1):
      for a in range(num): 
          for a in range(3): 
              t.forward(80) 
              t.left(120)
          spaces_after()
  #=========#=========#=========#=========#
  def draw_square(num=1):
      for a in range(num): 
          for a in range(4): 
              t.forward(80) 
              t.left(90)
          spaces_after()
  #=========#=========#=========#=========#        
  def draw_rectangle(num=1):
      for a in range(num):
          for a in range(2): 
              t.forward(80) 
              t.left(90)
              t.forward(40)
              t.left(90)
          spaces_after()
  #=========#=========#=========#=========#
  def draw_pentagon(num=1):
      for a in range(num): 
          for a in range(5): 
              t.forward(50) 
              t.left(72)
          spaces_after()
  #=========#=========#=========#=========#        
  def draw_hexagon(num=1):
      for a in range(num): 
          for a in range(6): 
              t.forward(50) 
              t.left(60)
          spaces_after()
  #=========#=========#=========#=========#        
  def draw_octagon(num=1):
      for a in range(num): 
          for a in range(8): 
              t.forward(40) 
              t.left(45)
          spaces_after()
  #=========#=========#=========#=========#
  def draw_circle(num=1):
      for a in range(num): 
          t . circle(50)
          spaces_after()
  #=========#=========#=========#=========#=========#=========#=========#
  def main():
      start_point()
  
      draw_triangle()
      draw_square()
      draw_rectangle()
      draw_pentagon()
      draw_hexagon()
      draw_octagon()
      draw_circle()
  
      t.end_fill()
  
  #=========#=========#=========#=========#=========#=========#=========#
  if __name__ == "__main__":
      main()
  
  #=========#=========#=========#=========#=========#=========#=========#
  </code></pre>