Python Palindrome | Easier now

Python palindrome using which we can find out whether the given string matches the reversed way of string.

For example :

madam = madam (reversed)

Enter the string

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
string = input("Enter a string: ")
string = input("Enter a string: ")
string = input("Enter a string: ")

reverse the string

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
reverse = string[::-1]
reverse = string[::-1]
reverse = string[::-1]

If the string matches then this block get’s executed.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
if string == reverse:
print("The string is a palindrome")
if string == reverse: print("The string is a palindrome")
if string == reverse:
    print("The string is a palindrome")

else

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
else:
print("The string is not a palindrome")
else: print("The string is not a palindrome")
else:
    print("The string is not a palindrome")

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
string = input("Enter a string: ")
reverse = string[::-1]
if string == reverse:
print("The string is a palindrome")
else:
print("The string is not a palindrome")
string = input("Enter a string: ") reverse = string[::-1] if string == reverse: print("The string is a palindrome") else: print("The string is not a palindrome")
string = input("Enter a string: ")
reverse = string[::-1]

if string == reverse:
    print("The string is a palindrome")
else:
    print("The string is not a palindrome")