This code isn't working and is just returning "Is a Palindrome", I believe it is a slicing problem of sorts. Please help!

#!/usr/bin/env python
x = input("Enter here: ")
x is x[:-1]
if True:
    print ("Is a Palindrome")
else:
    print ("Is Not a Palindrome")

Yes but what other way is there to compare the reversed input? Why is it always true?

condition follows the if keyword, you also must not use identical object comparison 'is' but equality.

Example of if statement:-

myVar1 = 6
myVar2 = 8
if 6 == 8:
    print("Equal")
elif 6 > 8:
    print("More")
else:
    print("Less")

Or it can be used like this:-

x = 5
print("x = 5" if x == 5 else "x != 5")

@OP
what Py Tony is saying is that your line(s)

if True:
    print ("Is a Palindrome")

will always execute, and

else:
    print ("Is Not a Palindrome")

will never execute. In programming, by saying if True: you are setting yourself up for an absolute decision. This is like deciding to jump off a cliff with no bungie, parachute, any clothes on, and saying "you know what, I probably shouldn't have done this." By the time you hit the ground, your done for, and all other options are off the table. Just be careful that your if...else statements work out properly =D

#!/usr/bin/env python
x = input("Enter here: ")
if x is x[:-1]:
    print ("Is a Palindrome")
else:
    print ("Is Not a Palindrome")

if True: does 'is true true? yes!'

This article has been dead for over six months. Start a new discussion instead.