Answers for "how to check for a number in range and even in python"

12

python check if number is in range

if 10000 <= number <= 30000:
    pass
Posted by: Guest on April-03-2020
1

python 3 numbers of a range is even

def check(element):
    return all(ord(i)%2 == 0 for i in element)  # all returns True if all digits i is even in element

lst = [str(i) for i in range(1000,3001)]        # creates list of all given numbers with string data type
lst = list(filter(check,lst))                   # filter removes element from list if check condition fails
print(",".join(lst))
Posted by: Guest on February-10-2020

Code answers related to "how to check for a number in range and even in python"

Python Answers by Framework

Browse Popular Code Answers by Language