# All palindrome numbers in a list

Given a list, count and print all the palindrome numbers in it.

Examples:

```Input: 10 121 133 155 141 252
Output: 121 141 252
Total palindrome nos. are 3

Input: 111 220 784 565 498 787 363
Output: 111 565 787 363
Total palindrome nos. are 4
```

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

1. Access an element from the list.
2. Now, in a temporary variable get its reverse value.
3. Now, compare the list element value by its reverse value, if both are same print the list element and increase the counter c by 1.
4. Carry on this procedure till list becomes empty.
5. Now, print the counter value i.e total number of palindrome numbers in given list.

 `# Python program to count and  ` `# print all palindrome numbers in a list. ` ` `  `def` `palindromeNumbers(list_a):  ` ` `  `    ``c ``=` `0` ` `  `    ``# loop till list is not empty ` `    ``for` `i ``in` `list_a:              ` ` `  `        ``# Find reverse of current number ` `        ``t ``=` `i ` `        ``rev ``=` `0` `        ``while` `t > ``0``: ` `            ``rev ``=` `rev ``*` `10` `+` `t ``%` `10` `            ``t ``=` `t ``/` `10` ` `  `        ``# compare rev with the current number ` `        ``if` `rev ``=``=` `i: ` `            ``print` `i, ` `            ``c ``=` `c ``+` `1` ` `  `    ``print` `    ``print` `"Total palindrome nos. are"``, c ` `    ``print` ` `  `# Driver code ` `def` `main(): ` ` `  `    ``list_a ``=` `[``10``, ``121``, ``133``, ``155``, ``141``, ``252``] ` `    ``palindromeNumbers(list_a) ` ` `  `    ``list_b ``=` `[ ``111``, ``220``, ``784``, ``565``, ``498``, ``787``, ``363``] ` `    ``palindromeNumbers(list_b)                      ` ` `  `if` `__name__``=``=``"__main__"``: ` `    ``main()             ``# main function call `

Output:

```121 141 252
Total palindrome nos. are 3

111 565 787 363
Total palindrome nos. are 4
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

1

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.