Python Programming Polindrome Number

What is polindrome number?

number and reversal of that number must be same. Example: 2112 is the polindrome number

Python Program to find next polindrome number

#!/usr/bin/python                                                               
                                                                                
def get_reverse_str(str_num):                                                   
    reversed_str = ""                                                           
    index = len(str_num) - 1                                                    
    while(index >= 0):                                                          
        reversed_str += str_num[index]                                          
        index -=1                                                               
    return reversed_str                                                         
                                                                                
def get_next_polyndrome_number(num):                                            
    count = num + 1                                                             
    while(True):                                                                
        str_num = str(count)                                                    
        reverse_num = get_reverse_str(str_num)                                  
        if(str_num == reverse_num):                                             
            break;                                                              
        count += 1                                                              
    return count                                                                
                                                                                
print("To find polyndrome number next to this number")                          
start_num = int(raw_input('Enter number: '))                                    
print(get_next_polyndrome_number(start_num))                                           
                                

Output:
$ python polyndrome.py 
To find polyndrome number next to this number
Enter number: 2090
2112

Privacy Policy  |  Copyright@2017 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^