bonjour,
là je commence à
"je suis novice dans la programmation python surtout en ce qui concerne les séquence"
j'ai l'énoncé suivant:
On vous demande d’écrire une fonction plus_grand_bord(w) qui, étant donné un mot w, retourne le plus grand bord de ce mot. On dit qu’un mot u est un bord de w, si u est à la fois un préfixe strict (c’est-à-dire un texte avec la première partie du texte w non vide et non égal à w lui-même) de w et un suffixe strict (c’est-à-dire un texte avec la dernière partie du texte w non vide et non égal à w lui-même) de w. Si w n’a pas de bord, la fonction retourne une chaîne de caractères vide.
Exemple : 'a' et 'abda' sont des bords de 'abdabda'
En effet:
'abdabda' à la fois commence et se termine par 'a'
De même 'abdabda' à la fois commence et se termine par 'abda'('abdabda' et 'abdabda')
Le plus grand bord est 'abda'.
comme proposition j'ai fait:
l'exception "EOFError: EOF when reading a line" se déclenche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 def plus_grand_bord(w): u=input() if (u[0:]!="" and u[0:]!=w) and (u[::]!="" and u[::]!=w): print(u) else: print("") w= input() plus_grand_bord(w)
Partager