title: Using while loop to repeat a function that generates random numbers
body: <p>I am having trouble when using a <code>while</code> loop to repeat a function.</p>
  
  <p>I am not an American student so please be understanding of my English.
  I have no clue of what is going wrong and hope I can get some help.
  I am aware that I can append the random number in the function and return it.</p>
  
  <p>The question is:</p>
  
  <p>There is a dice with 5 sides and each side says a , b , c , d ,e. If I get a d or an e, I throw again and I log this until I get an a,b or a c. ex) if I throw the dice 5times I can get: d, e, d, d, a or something like this. In my program, I want to simulate this process. I want it so that the function randomnumbers can generate random numbers from 0~4. I want the main program to loop the process of getting random numbers via this function(mandatory). Then, I want the main program to retrieve these values and use it to determine what these numbers mean(0=a, 1=b, 2=c, 3=d, 4=e) on the dice and append them to a separate list. Finally I want to print the values in the list where I logged the values I got.</p>
  
  <p>I specifically have to do the following:</p>
  
  <blockquote>
    <ol>
    <li>The function should only return one random number, not a list</li>
    <li>The main program should be responsible for making a list and printing the value retrieved from the function.</li>
    </ol>
  </blockquote>
  
  <pre><code>def randomnumbers():
      r = 0
      import random
      r = random.randrange(0,5)
      return r
  
  abc = ["a", "b", "c", "d", "e"]
  
  List = []
  while randomnumbers()&gt;=3:
      List.append(abc[randomnumbers()])
  
  for i in List:
      print i
  </code></pre>