vendredi 23 octobre 2015

Generate a list of 6 random numbers between 1 and 6 in python

So this is for a practice problem for one of my classes. I want to generate a list of 6 random numbers between 1 and 6. For example,startTheGame() should return [1,4,2,5,4,6]

I think I am close to getting it but Im just not sure how to code it so that all 6 numbers are appended to the list and then returned. Any help is appreciated.

import random
def startTheGame():
    counter = 0
    myList = []
    while (counter) < 6:
        randomNumber = random.randint(1,6)

    myList.append(randomNumber)

    counter = counter + 1

    if (counter)>=6:
        pass
    else:

        return myList




Aucun commentaire:

Enregistrer un commentaire