Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Last active December 15, 2020 03:54
Show Gist options
  • Save Abhayparashar31/762c7e08c8e08c4e46e3dc1fb954befb to your computer and use it in GitHub Desktop.
Save Abhayparashar31/762c7e08c8e08c4e46e3dc1fb954befb to your computer and use it in GitHub Desktop.
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