English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Donné une chaîne, notre tâche est de vérifier si cette chaîne est un palindrome.
: Étape1: Entrez la chaîne en tant qu'entrée. : Étape2: En utilisant la coupe de chaîne, nous inversons la chaîne et la comparons à la chaîne originale. : Étape3: Ensuite, affichez le résultat.
my_string=input("Entrez la chaîne:") if(my_string==my_string[::-1]: print("La chaîne est un palindrome") else: print("La chaîne n'est pas un palindrome")
Résultat de la sortie
Entrez la chaîne:madam La chaîne est un palindrome Entrez la chaîne:python La chaîne n'est pas un palindrome