Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

map and filter in python

>>> doubled_odds = map(lambda n: n * 2, filter(lambda n: n % 2 == 1, numbers))
>>> doubled_odds = [n * 2 for n in numbers if n % 2 == 1]
Comment

python map and filter

#Using map() and filter() functions add 2000 to the values below 8000.
lst1=[1000, 500, 600, 700, 5000, 90000, 17500]

lst2= list(map(lambda x: x+2000, filter(lambda x: x<8000, lst1)))
print(lst2)

#output = [3000, 2500, 2600, 2700, 7000]
Comment

python map and filter

lst2 = list(map(lambda x: x+2000, filter(lambda x: x<8000, lst1)))
Comment

PREVIOUS NEXT
Code Example
Python :: kill and run process in windows python 
Python :: pandas convert numbers in parentheses to negative 
Python :: python 7zip extract 
Python :: seaborn iris dataset 
Python :: pandas description of dataframe 
Python :: ocaml add element to end of list 
Python :: legend matplotlib 
Python :: how to read panda column 
Python :: view all columns pandas 
Python :: sorting a list of dictionaries 
Python :: Discord python get member object by id 
Python :: merge multiple excel workssheets into a single dataframe 
Python :: seed python 
Python :: time.strftime("%H:%M:%S") in python 
Python :: python datetime compare date 
Python :: python check if list 
Python :: python strip 
Python :: how return the data timestamp after some days in python 
Python :: add cooldown to command discord.py 
Python :: get keys from dictionary python 
Python :: easy frequency analysis python 
Python :: transformer un dictionnaire en liste python 
Python :: combination without repetition python 
Python :: int to alphabet letter python 
Python :: .describe() python 
Python :: get user django 
Python :: adding text cv2 
Python :: sqlalchemy_database_uri 
Python :: target ordinary encodiing) 
Python :: python run curl 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =