So i got this code to check if a number is a palindrome and it works fine but i got a question on the usage of some operator in the while
loop. The operator //
that is used between the original variable and integer 10
. What is it doing to the original p
value , is it dividing or? Here is the code am using
def test_palindrome(p):
o=p#store the original value of p in some variable
reversed_number=0#declare reversed_number and init to zero
while(p>0):
rem=p%10#Get the remainder of argument and ten
reversed_number=reversed_number*10+rem
p=p//10#This is the operator whose function is in question, am not sure if its dividing
if(reversed_number==o):#do comparison with original input and return
print(f"{o} is a palindrome")
else:
print(f"{o} is not a palindrome")
test_palindrome(number)