What filter( ) function does in Python? #programming #coding #python #codinghacks

preview_player
Показать описание
Hello Dear Coder,
In this video, we will learn about this super useful filter( ) function in Python. We will learn how this can be a good practice to use this function.
Stay tuned....

#python #programming #coding
Рекомендации по теме
Комментарии
Автор

x = [1, 2, 3, 4, 5, 6]
for i in x:
if i%2 != 0:
x.remove(i)

print(x)

😎

AbdoMhamed-cn
Автор

I wonder if there's any example of filter than can't be done with list comprehension

peterbarraud
Автор

My code is not working
def is_even():
n % 2 == 0
return

n = int(input("Enter the Value: "))
nums = []
for i in range(1, n+1):
nums.append(i)
print(nums)

even_num = filter(is_even, nums)
print(list(even_num))

ankit_aug