forked from DhruvBajaj01/Python_Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindromeChecker.py
More file actions
29 lines (22 loc) · 796 Bytes
/
PalindromeChecker.py
File metadata and controls
29 lines (22 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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}")