- Related Questions & Answers
- Average of even numbers till a given even number?
- Total number of non-decreasing numbers with n digits
- Find the sum of digits of a number at even and odd places in C++
- Find sum of even factors of a number in Python Program
- Python Program for Find sum of even factors of a number
- Sum of Even Numbers After Queries in Python
- Find the count of maximum contiguous Even numbers in C++
- Find numbers whose sum of digits equals a value
- How to output the number of n-valued Fibonacci numbers if upper digit is even with python
- Numbers With Repeated Digits in C++
- Python Program for Difference between sums of odd and even digits
- 8085 program to find the sum of series of even numbers
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers - JavaScript
- Find sum of even factors of a number using C++.
- Find sum of digits in factorial of a number in C++

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Suppose we have a list of numbers. We have to count the numbers that has even number of digit count. So if the array is like [12,345,2,6,7896], the output will be 2, as 12 and 7896 has even number of digits

To solve this, we will follow these steps −

- Take the list and convert each integer into string
- if the length of string is even, then increase count and finally return the count value

Let us see the following implementation to get better understanding −

class Solution(object): def findNumbers(self, nums): str_num = map(str, nums) count = 0 for s in str_num: if len(s) % 2 == 0: count += 1 return count ob1 = Solution() print(ob1.findNumbers([12,345,2,6,7897]))

[12,345,2,6,7897]

2

Advertisements