Last active
December 15, 2020 03:54
-
-
Save Abhayparashar31/762c7e08c8e08c4e46e3dc1fb954befb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lst = [1,2,3,4,5,6,7,8,9,10] ## iterable object | |
| def even_or_odd(num): ## Function to check even and odd | |
| if num%2==0: | |
| return "even" | |
| else: | |
| return "odd" | |
| list(map(even_or_odd,lst)) ## using map we are applying the function to each element of the ierable which will check whether the element is even or odd | |
| ----------------------------------------- | |
| ['odd', 'even', 'odd', 'even', 'odd', 'even', 'odd', 'even', 'odd', 'even'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment