Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

separete even and odd numbers from a list by filter in python

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 45, 89, 63, 74, 85, 96, ]
even = list(filter(lambda x: x % 2 == 0, numbers))
ec = len(even)
print("Even numbers:", even)
print("Total even numbers =", ec)

odd = list(filter(lambda x: x % 2 != 0, numbers))
oc = len(odd)
print("Odd numbers:", odd)
print("Total odd numbers =", oc)

Comment

PREVIOUS NEXT
Code Example
Python :: python if corto 
Python :: how to access specific index of matrix in python 
Python :: cashier program with class python 
Python :: Which of the following is not a core data type in Python programming? 
Python :: how to show type of a variable 
Python :: Trying to set up flask with nginx and gunicorn 
Python :: python assert multiple conditions 
Python :: Determining the Data Type 
Python :: jupyter lab move tabs 
Python :: Evaluate mathematical expression 
Python :: np sign no 0 
Python :: pandas maxima and minima for given column 
Python :: ring Reverse List Item 
Python :: protilipi get text python 
Python :: list duplicate files in folder python 
Python :: ring Desktop, WebAssembly and Mobile Using QTreeView and QFileSystemModel 
Python :: importing cosine from scipy 
Python :: Proper Case django template 
Python :: zero error 
Python :: python mayusculas 
Python :: dbscan multidimensional data 
Python :: bar plot with patterns colors 
Python :: python how to dump exception stak 
Python :: creating environment variable in python 
Python :: convert json file to dict - if comming as list 
Python :: how travel a list invertida in python 
Python :: apa itu duck typing python 
Python :: how to take input a matrix using map in python 
Python :: standardscalar 
Python :: how to fetch reverse foreign key on model object django 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =