- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

# Program to count number of elements in a list that contains odd number of digits in Python

Suppose we have a list of positive numbers called nums, we have to find the number of elements that have odd number of digits.

So, if the input is like [1, 300, 12, 10, 3, 51236, 1245], then the output will be 4

To solve this, we will follow these steps −

- c:= 0
- for i in range 0 to size of nums, do
- s:= digit count of nums[i]
- if s is odd, then
- c:= c+1

- return c

Let us see the following implementation to get better understanding −

## Example

class Solution: def solve(self, nums): c=0 for i in range(len(nums)): s=len(str(nums[i])) if s%2!=0: c=c+1 return c ob = Solution() print(ob.solve([1, 300, 12, 10, 3, 51236, 1245]))

## Input

[1, 300, 12, 10, 3, 51236, 1245]

## Output

4

- Related Questions & Answers
- Golang Program to Count the Number of Digits in a Number
- Find count of digits in a number that divide the number in C++
- Write a program in Python to count the number of digits in a given number N
- Program to count number of stepping numbers of n digits in python
- Python | Sum of number digits in List
- Python Program to Find Element Occurring Odd Number of Times in a List
- Count odd and even digits in a number in PL/SQL
- Program to count number of valid pairs from a list of numbers, where pair sum is odd in Python
- Java Program to Count Number of Digits in an Integer
- Program to find nearest number of n where all digits are odd in python
- Count number of items in a dictionary value that is a list in Python
- Java program to Count the number of digits in a given integer
- Program to count number of points that lie on a line in Python
- Count number of even and odd elements in an array in C++
- Program to count number of elements present in a set of elements with recursive indexing in Python

Advertisements