Problème avec une valeur suite à l'utilisation d'une boucle
Phil_1857 Messages postés 1872 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai un problème avec une valeur qui n'est pas la même a l'intérieur qu'en dehors de la boucle
voici mon script:
nom_pl1='messi'
nom_pl2='ronaldo'
point_pl1= 0
point_pl2= 0
jeu_pl1= 0
jeu_pl2= 0
set_pl1= 0
set_pl2= 0
while point_pl1 !=4 or point_pl2 !=4:
from random import randint
a = randint(0,1)
if a == 0:
point_pl1 += 0
point_pl2 += 1
else:
point_pl1 +=1
point_pl2 +=0
if point_pl1 >4:
break
if point_pl2 >4:
break
print(f"{point_pl1} {nom_pl1}")
print(f"{point_pl2} {nom_pl2}")
from random import randint
b = randint(0,1)
if b == 0:
point_pl1 += 0
point_pl2 += 1
else:
point_pl1 +=1
point_pl2 +=0
if point_pl1 >4:
break
if point_pl2 >4:
break
print(f"{point_pl1} {nom_pl1}")
print(f"{point_pl2} {nom_pl2}")
from random import randint
c = randint(0,1)
if c == 0:
point_pl1 += 0
point_pl2 += 1
else:
point_pl1 +=1
point_pl2 +=0
if point_pl1 >4:
break
if point_pl2 >4:
break
print(f"{point_pl1} {nom_pl1}")
print(f"{point_pl2} {nom_pl2}")
from random import randint
d = randint(0,1)
if d == 0:
point_pl1 += 0
point_pl2 += 1
else:
point_pl1 +=1
point_pl2 +=0
if point_pl1 >4:
break
if point_pl2 >4:
break
if point_pl1 ==4 and point_pl2 !=0:
break
if point_pl2 ==4 and point_pl1 !=0:
break
if point_pl1 >4:
break
if point_pl2 >4:
break
print(f"{point_pl1} {nom_pl1}")
print(f"{point_pl2} {nom_pl2}")
print(f"{point_pl1}")
print(f"{point_pl2}")
Windows / Chrome 107.0.0.0
- Problème avec une valeur suite à l'utilisation d'une boucle
- Utilisation chromecast - Guide
- Télécharger gratuitement notice d'utilisation - Guide
- Utiliser une tablette comme ecran pc - Guide
- Logiciel gratuit calcul valeur nutritionnelle - Télécharger - Santé & Bien-être
- Mon pc s'allume et s'éteint en boucle - Forum Matériel & Système
3 réponses
Bonjour,
on y verrait plus clair si tu affichais ton code avec les balises de code
mode d'emploi:
https://codes-sources.commentcamarche.net/faq/11288-poster-un-extrait-de-code
Visuellement, ça doit ressembler à ça:
for k in range(10): print(k)
C'est normal:
tu affiches dans la boucle point_pl1 qui est égal à 4
ensuite tu refais un tour de boucle en incrémentant point_pl1, qui passe donc à 5 et comme il est > 4 : break,
on sort de la boucle sans repasser sur les print
donc après la boucle point_pl1 = 5 ! CQFD