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")

True is of course allways true so what else it could print, line 3 does nothing.

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!'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.