Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
filtering python3
list_of_stuff = [ "aus-airport-1", "aus-airport-2", "us-airport-1", "us-airport-2", "aus-ship-1", "us-ship-99", "nz-airport-1"] is_airport = lambda x: "-airport-" in x is_ship = lambda x: "-ship-" in x airports_excluding_nz = lambda x: is_airport(x) and not x.startswith("nz-") airports_in_aus = lambda x: is_airport(x) and x.startswith("nz-") ships = lambda x: is_ship(x) print ("all regions excluding nz:" , ", ".join( filter(lambda x: airports_excluding_nz(x) , list_of_stuff) ) ) print ("all regions in aus:", ", ".join( filter(lambda x: airports_in_aus(x) , list_of_stuff) ) ) print ("all ships:", ", ".join( filter(lambda x: ships(x) , list_of_stuff) ) )
run
|
edit
|
history
|
help
0
Iterator-1
Calculate Volume of Sphere
pip install pyowm==2.7.1
Homework exercise
inerse_matrix_gauss_jordan
Short python input
Яндекс.Интервью - Задача C
вправи в пайтон
gj4
probl2_203700377