Advertisement
kajs54

ex 2 s10

May 4th, 2022
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. def saisie():
  2. ch=input("enter ch:")
  3. return ch
  4. def palindrome(ch):
  5. test=True
  6. i=0
  7. j=len(ch)-1
  8. while test==True and j!=0 and i!=len(ch):
  9. if not (ch[i].upper()==ch[j].upper()):
  10. test=False
  11. return test==True
  12. def tpal(ch):
  13. x=""
  14. for i in range(len(ch)):
  15. for j in range(len(ch)-1,0,-1):
  16. if palindrome(ch[i:j])==True:
  17. x=ch[i:j]+","+x
  18. return ch[:-1]
  19. ch=saisie()
  20. print("les chaines suivantes:",tpal(ch))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement