Menu

gitpiper

some python Code Snippet in 2025

listintermediate

Last Updated: 2 February 2025

Checks if the provided function returns True for at least one element in the list.

  • Use any() in combination with map() to check if fn returns True for any element in the list.
def some(lst, fn = lambda x: x): return any(map(fn, lst))
some([0, 1, 2, 0], lambda x: x >= 2 ) # True some([0, 0, 1, 0]) # True

python snippet similar to some For You in February 2025

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2025 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️