title: Python function card deal
body: <p>Write a function, deal(numhands, n=5, deck), that 
   deals numhands hands with n cards each.</p>
  
  <pre><code>import random # this will be a useful library for shuffling
  from random import shuffle
  
  # This builds a deck of 52 cards. If you are unfamiliar with this
  # notation, check out Andy's supplemental video
  # on list comprehensions (you can find the link in the 
  # Instructor Comments box below).
  
  mydeck = [r+s for r in '23456789TJQKA' for s in 'SHDC'] 
  
  def deal(numhands, n=5, deck=mydeck):
      mynew = shuffle(deck)
      if numhands*n &gt; len(deck):
          raise Exception('Not enough cards.')
  
      hands = []
      for i in range(0,numhands):
          ncards = []
          for j in range(0,n):
              ncards.append(mynew.pop())
          hands.append(ncards)
      return hands    
  
  
  print deal(2)
  </code></pre>
  
  <p>I am not sure what is wrong with the function but it keeps telling me this error
  in deal
      ncards.append(mynew.pop())
  AttributeError: 'NoneType' object has no attribute 'pop'</p>