+ 2

Please help me!!! This program is to check palindrome number..... But it shows "nope" everytime....whatever the input is..

n=int(input("enter the number:")) nt=n; b=0; while nt>0: b=(b*10)+(n%10); nt=nt/10; if b==n: print("palin") else: print("nope")

16th Oct 2017, 2:33 PM
Siddhant Rai
Siddhant Rai - avatar
5 Réponses
+ 2
ohhh....i got it....python ,unlike java, takes the input based on values...in the statement (nt=nt/10)...it was giving the value in float and in my code i was comparing a int value to float value..example (121==121.111)...which is never ever true, so i modified the code to give only integer values....my new code is. . . . .. n=int(input("enter the number:")) nt=n; b=0; while nt>0: a=nt%10; b=(b*10)+a; nt=int(nt/10); if b==n: print("palin") else: print("nope")
16th Oct 2017, 2:50 PM
Siddhant Rai
Siddhant Rai - avatar
+ 1
please help me through
16th Oct 2017, 2:39 PM
Siddhant Rai
Siddhant Rai - avatar
+ 1
i like what you rout
16th Oct 2017, 2:39 PM
Sara Bess
Sara Bess - avatar
+ 1
what do u mean??
16th Oct 2017, 2:45 PM
Siddhant Rai
Siddhant Rai - avatar
+ 1
you can do with strings also....see this....(actually i am a noob, so, i am not well versed with python...) . . . .num =input("Enter any number: ") numt = reversed(num) if list(num)==list(numt): print("Palindrome number") else: print("Not Palindrome number")
16th Oct 2017, 2:52 PM
Siddhant Rai
Siddhant Rai - avatar