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
add lambda
validation
Mengira luas dan perimeter segi tiga
kenken1
Breadth-First Path Finding
playing around with python
calucation
inverse matrix gauss jordan
Принцип наименьшего времени Ферма
Add missing persons