+ 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")
5 ответов
+ 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")
+ 1
please help me through
+ 1
i like what you rout
+ 1
what do u mean??
+ 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")