Skip to content

test #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2022
Merged

test #22

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions lambda/example_lambda_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## RETURN THE NUMBER IF IT IS EVEN

# CHECK_EVEN FUNCTION DEFINE
def check_even(num):

# RETURN THE NUMBER IF THE CONDITION IS TRUE
return num%2==0

# GIVING INPUTS TO THE NUMS
nums = [1,2,3,4,5,6]

# HERE WE PRINT WITH THE FILTER AND IN LIST FORMAT
print(list(filter(check_even,nums)))

# PRINT USING FOR LOOP
for i in filter(check_even,nums):
print(i)

## SIMPLE OUTPUT
# HOW TO RUN
# PYTHON: example_lambda_filter.py
# [2, 4, 6]

## OUTPUT AFTER USING THE FOR LOOP
# PYTHON: example_lambda_filter.py
# 2
# 4
# 6