Why this reverse string logic in java wont work in python? -


please explain why logic wont work in python. works in java?

def reverse(number): reversednumber = 0; temp = 0;  while(number > 0):     #use modulus operator strip off last digit     temp = number%10;     print(temp) #4     #create reversed number     reversednumber = reversednumber * 10 + temp;     number = number/10;     print("reversednumber", reversednumber) 

reverse(1234)

in python 3 dividing 2 integers can return float. in languages 1/2 == 0. in python 3 1/2 == 0.5. integer division in python 3 use double division sign, i.e. 1//2 == 0.

note, difference between python 2 , 3.

also not work because comments in python written starting # not //.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -