title: Serial Key Generation and Validation
body: <p>I'm toying around with writing creating a serial code generator/validator, but I can't seem to get how to do a proper check.</p>
  
  <p>Here's my generator code:</p>
  
  <pre><code># Serial generator
  
  # Create sequences from which random.choice can choose
  Sequence_A = 'ABCDEF'
  Sequence_B = 'UVWQYZ'
  Sequence_C = 'NOPQRS'
  Sequence_D = 'MARTIN'
  
  import random
  
  # Generate a series of random numbers and Letters to later concatenate into a pass code
  First = str(random.randint(1,5))
  Second = str(random.choice(Sequence_A))
  Third = str(random.randint(6,9))
  Fourth = str(random.choice(Sequence_B))
  Fifth = str(random.randint(0,2))
  Sixth = str(random.choice(Sequence_C))
  Seventh = str(random.randint(7,8))
  Eighth = str(random.choice(Sequence_D))
  Ninth = str(random.randint(3,5))
  
  
  serial = First+Second+Third+Fourth+Fifth+Sixth+Seventh+Eighth+Ninth
  
  print serial
  </code></pre>
  
  <p>I'd like to make a universal check so that my validation code will accept any key generated by this.</p>
  
  <p>My intuition was to create checks like this:</p>
  
  <pre><code>serial_check = raw_input("Please enter your serial code: ")
  
  # create a control object for while loop
  control = True
  
  # Break up user input into list that can be analyzed individually
  serial_list = list(serial_check)    
  
  while control:
      if serial_list[0] == range(1,5):
          pass
      elif serial_list[0] != range(1,5):
          control = False
  
      if serial_list[1] == random.choice('ABCDEF'):
          pass
      elif serial_list[1] != random.choice('ABCDEF'):
          control = False
  # and so on until the final, where, if valid, I would print that the key is valid.
  
  if control == False:
        print "Invalid Serial Code"
  </code></pre>
  
  <p>I'm well aware that the second type of check won't work at all, but it's a place holder because I've got no idea how to check that.</p>
  
  <p>But I thought the method for checking numbers would work, but it doesn't either.</p>