How to filter out any digit that contains odd number in a range of number in Python

–1 vote
I want to filter out any number that contains a odd digit in it, this should happen in a range of number.

e.g.

1-10 must give an output as follows:

2 4 6 8
Nov 19, 2018 in Python by Jino
• 5,820 points
2,269 views

2 answers to this question.

0 votes

This code will work:

scsv = ""
for i in range (1000,3001):
    if i % 2 == 0:
        if '1' not in str(i) and '3' not in str(i) and '5' not in str(i) and '7' not in str(i) and '9' not in str(i):
             scsv = scsv+str(i)+" , "
print (scsv[:-3])

This code is very basic but serves the purpose.

answered Nov 19, 2018 by Nabarupa
0 votes
n = list(range(10))

b = list(filter(lambda i:i%2!=0,n))

print(b)
answered Oct 1, 2019 by Nomizo_Coders

Related Questions In Python

0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2, 2019 in Python by anonymous
5,857 views
0 votes
1 answer

How to find exponent of a number in Python?

Yes you can do it using the ...READ MORE

answered Jul 2, 2019 in Python by Arvind
• 3,050 points
2,305 views
0 votes
1 answer

How to check if a float value(decimal number) is between range(0 to 10) in python

Hello,  A function that returns True for an integer number (int or ...READ MORE

answered Sep 14, 2020 in Python by Niroj
• 82,840 points
7,105 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+1 vote
1 answer
0 votes
2 answers

How to check whether a string contains alphabets or number in Python?

By using isAlpha () to check whether ...READ MORE

answered Jul 14, 2019 in Python by Sheik janibasha
5,384 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP