This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatique:python [2024/12/11 22:47] – yahiko | informatique:python [2024/12/13 21:11] (current) – yahiko | ||
---|---|---|---|
Line 144: | Line 144: | ||
Je ne sais pas, un '' | Je ne sais pas, un '' | ||
<code python> | <code python> | ||
- | def DashCheck(dash): | + | def DashCheck(check): |
- | if dash == ' | + | if check == ' |
- | IsDash | + | dash = str(" |
else: | else: | ||
- | IsDash | + | dash = str(" |
- | return | + | return |
print(DashCheck(" | print(DashCheck(" | ||
</ | </ | ||
Va retourner '' | Va retourner '' | ||
+ | |||
+ | Et si on veut supprimer ce dernier '' | ||
+ | <code python> | ||
+ | def DashCheck(check): | ||
+ | # On vérifie le dernier caractère de la chaîne | ||
+ | if check[-1] == ' | ||
+ | # Si " | ||
+ | dash = check[:-1] | ||
+ | return dash | ||
+ | else: | ||
+ | return check | ||
+ | </ | ||