Python Problem 4: Solution | Python Tutorials For Absolute Beginners In Hindi #110

►Full Python tutorials for absolute beginners (Hindi) playlist - https://www.youtube.com/playlist?list=PLu0W_9lII9agICnT8t4iYVSZ3eykIAOME
►Click here to subscribe - https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww

Code as described/written in the video

'''
Author: Harry
Date: 15 April 2019
Purpose: Practice Problem For CodeWithHarry Channel 
'''


def next_palindrome(n):
    n = n+1
    while not is_palindrome(n):
        n += 1
    return n


def is_palindrome(n):
    return str(n) == str(n)[::-1]


if __name__ == "__main__":
    n = int(input("Enter the number of test cases\n"))
    numbers = []
    for i in range(n):
        number = int(input("Enter the number:\n"))
        numbers.append(number)

    for i in range(n):
        print(
            f"Next palindrome for {numbers[i]} is {next_palindrome(numbers[i])}")



Be the first person to comment!

Comments(0)