From d09a08b6fe6d03c3ad5d12789ba9d61c3e3aabc1 Mon Sep 17 00:00:00 2001 From: adarshK0508 <72150713+adarshK0508@users.noreply.github.com> Date: Fri, 1 Oct 2021 18:00:04 +0530 Subject: [PATCH] Add files via upload --- PalindromeChecker.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 PalindromeChecker.py diff --git a/PalindromeChecker.py b/PalindromeChecker.py new file mode 100644 index 0000000..0f5a370 --- /dev/null +++ b/PalindromeChecker.py @@ -0,0 +1,29 @@ +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__": + size = int(input("Enter the size of your list\n")) + num_list = [] + for i in range(size): + num_list.append(int(input("Enter the number of the list\n"))) + print(f"You have entered {num_list}") + + print(f"Output List: {[num_list[i] if num_list[i] < 10 else next_palindrome(num_list[i] ) for i in range(size)]}") + + + # new_list = [] + # for element in num_list: + # if element >10: + # n = next_palindrome(element) + # new_list.append(n) + + # else: + # new_list.append(element) + # print(f"Output List: {new_list}")