norminette ex06

This commit is contained in:
hugogogo
2025-10-26 20:27:34 +01:00
parent 6f83006187
commit 49461a0b25
2 changed files with 3 additions and 2 deletions

View File

@@ -5,7 +5,8 @@ def ft_filter(function, iterable):
Return an iterator yielding those items of iterable for which function(item) Return an iterator yielding those items of iterable for which function(item)
is true. If function is None, return the items that are true.""" is true. If function is None, return the items that are true."""
# iter https://docs.python.org/3.10/library/functions.html?highlight=iter#iter # iter
# https://docs.python.org/3.10/library/functions.html?highlight=iter#iter
if function is None: if function is None:
return iter([item for item in iterable if item]) return iter([item for item in iterable if item])
else: else:

View File

@@ -16,4 +16,4 @@ print("- 3 filter :", list(filter(None, msg)))
print(" ft_filter :", list(ft_filter(None, msg))) print(" ft_filter :", list(ft_filter(None, msg)))
print("- 4 filter :", list(filter(str.isupper, msg))) print("- 4 filter :", list(filter(str.isupper, msg)))
print(" ft_filter :", list(ft_filter(str.isupper, msg))) print(" ft_filter :", list(ft_filter(str.isupper, msg)))