vendredi 6 novembre 2015

trying to get python to randomly shuffle the list mycolours, but want python to only return 4 from the list

This is my code:

def main():
    mycolours = ['R', 'G', 'B', 'Y', 'P', 'O']
    myguess = 'RGBY'
    total_guess = 5
    x = random.shuffle(mycolours[:4])

    for i in range(total_guess):
        if myguess == x:
            print('CORRECT')
        else: 
            print('TRY AGAIN')
main()

Instead of x returning 4 random strings from the list it returns a value of none.




Aucun commentaire:

Enregistrer un commentaire