title: Creating a list of random numbers without duplicates in python
body: <p>so what I am trying to do is create a list of 5 numbers for the game mastermind, and I would like to eliminate all duplicates! The issue is that the code sometimes creates a list with 3 numbers, or 4, or sometimes 5, it seems to be random.   </p>
  
  <p>I should also mention we are not allowed to be usin grandom.sample, or random.shuffle</p>
  
  <pre><code>import random
  
  def generatePassword() :
      lis = []
      for i in range(5) :
          #This checks to see if there are duplicate numbers
          r = random.randint(1,9)
          if r not in lis :
              lis.append(r)
          i+=1
      return lis
  
  
  
  def main() :
      print(generatePassword())
  main()
  </code></pre>