title: Bulls and Cows Game - Python programming for beginners
body: <p>I am a beginer programming Python and for a evaluation assignment I was asked to program a Bulls and Cows game using very simple code.
  I have some code already written, but can't seem to make the function work. The function should be able to compare the four digit number the user wrote (num_guess) to the random number generated by the program (stored in a list called num).
  I can input the value, but have no further feedback from the program. 
  Could you please check my code and help me?
  Thanks!</p>
  
  <pre><code>import random
  
  guess = raw_input("What is your guess? ") 
  if (len(guess) != 4): 
      guess = raw_input("Your guess must be 4 characters long! What is your guess?")
  
  num_guess = []  
  for c in guess:  
      num_guess.append(int(c)) 
  
  def compare(num_guess):
      num = []  
      for i in range(4):  
          n = random.randint(0, 9)  
          while n in num: 
              n = random.randint(0, 9)
          num.append(n)
  
   if num_guess == num: 
       print "Congratulations! Your guess is correct"
  
   output = []
  
   if num_guess[0] == num [0]:
      output.append["B"]
   else:
       output.append["C"]
  
   if num_guess[1] == num [1]:
       output.append["B"]
   else:
       output.append["C"] 
  
   if num_guess[2] == num [2]:
       output.append["B"]
   else:
       output.append["C"] 
  
   if num_guess[3] == num [3]:
       output.append["B"]
   else:
       output.append["C"]
  
   return output
  
  nguesses = 0
  while nguesses &lt; 11:
  nguesses = nguesses + 1, compare 
  </code></pre>