# Python: Find an integer with the given number of even and odd digits

## Python Programming Puzzles: Exercise-88 with Solution

Write a Python program to find an integer (n >= 0) with the given number of even and odd digits.

Input: Number of even digits: 2 ,Number of odd digits: 3 Output: 22333 Input: Number of even digits: 4 ,Number of odd digits: 7 Output: 22223333333

**Sample Solution:**

**Python Code:**

```
#License: https://bit.ly/3oLErEI
def test(a,b):
return int(evens*"2"+odds*"3")
evens = 2
odds = 3
print("Number of even digits:",evens,",Number of odd digits:",odds)
print("Integer(>= 0) with the given number of even and odd digits:")
print(test(evens, odds))
evens = 4
odds = 7
print("\nNumber of even digits:",evens,",Number of odd digits:",odds)
print("Integer(>= 0) with the given number of even and odd digits:")
print(test(evens, odds))
```

Sample Output:

Number of even digits: 2 ,Number of odd digits: 3 Integer(>= 0) with the given number of even and odd digits: 22333 Number of even digits: 4 ,Number of odd digits: 7 Integer(>= 0) with the given number of even and odd digits: 22223333333

**Flowchart:**

**Python Code Editor :**

**Have another way to solve this solution? Contribute your code (and comments) through Disqus.**

**Previous:** Find a valid substring of s that contains matching brackets, at least one of which is nested.

**Next:** Find all integers that are the product of exactly three primes.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

**Weekly Trends**- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join