[Python] Besoin d'aide (instruct random ?)
Fermé
Python_newbie
Messages postés
3
Date d'inscription
mercredi 21 mai 2003
Statut
Membre
Dernière intervention
26 mai 2003
-
25 mai 2003 à 19:44
Python_newbie Messages postés 3 Date d'inscription mercredi 21 mai 2003 Statut Membre Dernière intervention 26 mai 2003 - 26 mai 2003 à 12:50
Python_newbie Messages postés 3 Date d'inscription mercredi 21 mai 2003 Statut Membre Dernière intervention 26 mai 2003 - 26 mai 2003 à 12:50
A voir également:
- [Python] Besoin d'aide (instruct random ?)
- Citizen code python avis - Accueil - Outils
- Python generator - Télécharger - Sécurité
- Trouver la position d'un élément dans une liste python ✓ - Forum Python
- Mot secret python pix ✓ - Forum Python
2 réponses
sebsauvage
Messages postés
32893
Date d'inscription
mercredi 29 août 2001
Statut
Modérateur
Dernière intervention
21 octobre 2019
15 662
26 mai 2003 à 09:38
26 mai 2003 à 09:38
Et pourquoi pas mettre le nom de tes images dans un tableau ?
Il suffirait ensuite d'utiliser random pour choisir au hasard 3 images dans ce tableau !
nom_fichiers = ['cpython/images/im1.gif',
'cpython/images/im2.gif',
'cpython/images/im3.gif',
'cpython/images/im4.gif',
'cpython/images/im5.gif',
'cpython/images/im6.gif',
'cpython/images/im7.gif',
'cpython/images/im8.gif' ]
Puis pour choisir 3 noms au hasard dans cette liste:
nom1 = random.choice(nom_fichiers)
nom2 = random.choice(nom_fichiers)
nom3 = random.choice(nom_fichiers)
Il suffirait ensuite d'utiliser random pour choisir au hasard 3 images dans ce tableau !
nom_fichiers = ['cpython/images/im1.gif',
'cpython/images/im2.gif',
'cpython/images/im3.gif',
'cpython/images/im4.gif',
'cpython/images/im5.gif',
'cpython/images/im6.gif',
'cpython/images/im7.gif',
'cpython/images/im8.gif' ]
Puis pour choisir 3 noms au hasard dans cette liste:
nom1 = random.choice(nom_fichiers)
nom2 = random.choice(nom_fichiers)
nom3 = random.choice(nom_fichiers)
Python_newbie
Messages postés
3
Date d'inscription
mercredi 21 mai 2003
Statut
Membre
Dernière intervention
26 mai 2003
26 mai 2003 à 12:50
26 mai 2003 à 12:50
Merci infiniement , je crois que c'est vraiment la meilleure solution !
python_Newbie
python_Newbie