samedi 23 décembre 2017

generate random message from a list

I need some help with a Python code

So I'm using this code to pick 3 words to form a message from the 5 words randomly.

def randomMessage():    
    word = ['Animal', 'Dog', 'Cat', 'Queen', 'Bird']

    return (random.sample(word, 3))

and then in a later part of the code, i want to put this in a message using

" + randomMessage() + "

But it gives me error saying "must be str, not a list"

How can i fix this?




Aucun commentaire:

Enregistrer un commentaire