Sos, code incorrrect
blue
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour,
je n'arrive pas à comprendre ce qui ne va pas avec ce code
def verif (ch):
test=True
j=0
while (j<len(ch)) and test:
if not ("A"<=ch[j].upper()<="Z") or ch[j]==" ":
test=False
j=j+1
return ch!="" and test
def saisie():
global N
N= int (input("Donnez un entier N"))
while not 2<=N<=25:
N= int (input("Donnez un entier N valide"))
def remp(T,N):
for i in range (N):
T[i]=input("Entrez une chaine de caractères")
while not(verif (T[i]) and len(T[i])<=20):
T[i]=input("Entrez une chaine de caractères valide")
def voy (ch):
c=0
for i in range (len (ch)):
if ch[i].upper() in {"OIYEAU"}:
c=c+1
return c
#pp
saisie()
T=[""]*N
remp(T,N)
for i in range (N):
max= ""
if voy (T[i])> voy(T[i+1]):
max= T[i]
print(max)
je n'arrive pas à comprendre ce qui ne va pas avec ce code
def verif (ch):
test=True
j=0
while (j<len(ch)) and test:
if not ("A"<=ch[j].upper()<="Z") or ch[j]==" ":
test=False
j=j+1
return ch!="" and test
def saisie():
global N
N= int (input("Donnez un entier N"))
while not 2<=N<=25:
N= int (input("Donnez un entier N valide"))
def remp(T,N):
for i in range (N):
T[i]=input("Entrez une chaine de caractères")
while not(verif (T[i]) and len(T[i])<=20):
T[i]=input("Entrez une chaine de caractères valide")
def voy (ch):
c=0
for i in range (len (ch)):
if ch[i].upper() in {"OIYEAU"}:
c=c+1
return c
#pp
saisie()
T=[""]*N
remp(T,N)
for i in range (N):
max= ""
if voy (T[i])> voy(T[i+1]):
max= T[i]
print(max)
Configuration: Windows / Chrome 100.0.4896.75
A voir également:
- Sos, code incorrrect
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Code blocks - Télécharger - Langages
1 réponse
Bonjour
En Python, l’indentation est primordiale, or par défaut le site ne la conserve pas.
Pour la conserver il faut utiliser les balises de code. Voir ce petit tuto https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
On pourra commencer à essayer de t’aider quand tu auras reposté correctement ton code.
En Python, l’indentation est primordiale, or par défaut le site ne la conserve pas.
Pour la conserver il faut utiliser les balises de code. Voir ce petit tuto https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
On pourra commencer à essayer de t’aider quand tu auras reposté correctement ton code.