Transformer un code en fonction
Bonjour,
je vous préviens c'est vraiment une question de débutant, mais bon voilà,
j'ai fait le code suivant qui permet de chercher un mot au hasard dans une liste
Code:
1 2 3 4 5 6 7 8
|
import random
liste_mot = ["jouer","gagner","perdre"]
mot_hasard = random.choice(liste_mot)
print(mot_hasard) |
mais au fait j'ai tricher car on me demande de faire une fonction.
Donc j'ai fait ça (mais je ne vois rien qui s'affiche à l'écran alors que je voudrais afficher la variable : mot_hasard
Code:
1 2 3 4
|
def choix_mot(L):
mot_hasard = random.choice(L)
return mot_hasard |
la fonction ne plante pas, mais elle n'affiche rien...