from random import choice pioche = ['philo', 'maths'] def mot(s): return ''.join(s) def choix(): s = list('*' * 5) while mot(s) not in pioche: s = [choice([pioche[0][i], pioche[1][i]]) for i in range(5)] print(mot(s)) choix()
Create, edit, and import your Python scripts
from random import choice pioche = ['philo', 'maths'] def mot(s): return ''.join(s) def choix(): s = list('*' * 5) while mot(s) not in pioche: s = [choice([pioche[0][i], pioche[1][i]]) for i in range(5)] print(mot(s)) choix()