title: How do you compare the output of a function in python?
body: <p>Sorry if this is a obvious question, but I am 12 and trying to write some code to help me with my science project, where I am trying to see which lock is the most secure. Basically my problem is, I need to figure out how to compare the output of a function with the if somethinghere() == somethingelse(). And by the way, I am using the <code>random</code> module. As an example of what im trying to do, this is the comparing code part: </p>
  
  <pre class="lang-py prettyprint-override"><code>def guessfixed(y):     
          y = print ("[",(random.randint(0, 9)),", ",(random.randint(0, 9)),", ",(random.randint(0, 9)),", ",(random.randint(0, 9)),", ",(random.randint(0, 9)),"]",sep="") #this is supposed to keep changing until it is the same as the key.
          return y
  </code></pre>
  
  <p>for one part that I am comparing, all the [, ] things are to format it to compare it, and the other part I am comparing is</p>
  
  <pre class="lang-py prettyprint-override"><code>mylistkey = [] # the random generated key, this is supposed to stay the same.
  for i in range(0,5):
      x = random.randint(0,9)
      mylistkey.append(x)
  </code></pre>
  
  <p>and how I am trying to compare it is with:</p>
  
  <pre class="lang-py prettyprint-override"><code>while guessfixed(0) != mylistkey:
      if guessfixed(0) == mylistkey:
          print ("it worked!")
      if guessfixed(0) != mylistkey: #by the way, this is still in the loop
          print ("it did not quite work"),
  </code></pre>
  
  <p>The only way I know this is not working is because in the full script, I changed the key and guess to only have 4 combinations, so the key and the guess would have to overlap eventually, and it just kept going, supposedly trying 100 combos before I killed it. According to my tests, the guessfixed changes, and the key does not.
  And once again, thanks for reading this, and sorry if this is an off-topic question or is really obvious. I am 12, so I'm not that good at writing questions, but practice makes perfect!</p>