title: :TypeError: argument of type 'function' is not iterable", but works when individually tested
body: <p>I am a newbie to Python 2. I am trying to build a "shopping cart" Python program, but stuck at "check stock before put to cart" step.</p>
  
  <p>Firstly, I have read many threads of the same problems in here, but they are seemingly of different cause from mine.</p>
  
  <p>Secondly, I already separated each function and test in a different file. They worked well individually. But when joined back the <code>check_stock(y)</code> function, it gave the error.</p>
  
  <p>I believe that the problem comes from the "in" command.</p>
  
  <pre><code>    def check_stock(y):             #// Problem in this function // 
          if y in list:
              print "%s is available" % y
              add_to_cart(y)
          else:
              print "Sorry, but %s is not available." % y
  
      def check_finish():
          y = raw_input("&gt;")
          if y == "checkcart":        
              print cart              #check inside shopping cart
          elif y == " ":
              check_finish()          #loop back for blank
          elif y == "list":
              list()                  #present the list
          else:
              while y != "ok":        #"ok" = finished shopping
                  check_stock(y)
              else:
                  print "Checking out..."
                  sorted(cart)
                  print "Your item(s) are %s." % cart
                  exit(0)
  </code></pre>
  
  <p>Here are the rest of the code, if it may help:</p>
  
  <pre><code>cart = []
  list = ['apple', 'banana', 'cat', 'dog', 'elephant', 'flamingo', 'goofy', 'ham']
  a = 0
  
  def list():
      print list                  #present the list
  def representInt(s):            #check if value is integer
      try:
          int(s)
          return True
      except ValueError:
          return False
  def annoyedAtError(a):          #interaction for repeated mistakes
      if a &lt; 2:
          print "Numbers only please"
      elif 2 &lt; a &lt; 4:
          print "Man, just do as I say, please. I have another shift tonight."
      elif a == 5 :
          print "Hey, seriously?"
      else:
          print "..."
  def check_stock(y):             #// PROBLEM HERE // cross-check with list if item is available
      if y in list:
          print "%s is available" % y
          add_to_cart(y)
      else:
          print "Sorry, but %s is not available." % y
  
  def add_to_cart(y):
      amount = (raw_input("How many do you want to add? &gt; "))
      if representInt(amount) == False:
          annoyedAtError(a)
          global a 
          a = a + 1
          add_to_cart(y)
      else: 
          y = y + " " + amount
          print "%s is added to cart" % (y)
          cart.append(y)
          check_finish()
  def check_finish():
      y = raw_input("&gt;")
      if y == "checkcart":        
          print cart              #check inside shopping cart
      elif y == " ":
          check_finish()          #loop back for blank
      elif y == "list":
          list()                  #present the list
      else:
          while y != "ok":        #"ok" = finished shopping
              check_stock(y)
          else:
              print "Checking out..."
              sorted(cart)
              print "Your item(s) are %s." % cart
              exit(0)
  def welcome():      
      print """\nWelcome to cyber shopping.\n 
      Please enter things you want to buy.
      Check your cart by typing: checkcart
      type "ok" when finished.
      type "list" for things available for buying"""
  def start():
      welcome()
      check_finish()
  
  start()
  </code></pre>