Skip to content

Instantly share code, notes, and snippets.

@justxor
Created June 1, 2022 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justxor/c56eee6783636b73461c8cb3a77782ef to your computer and use it in GitHub Desktop.
Save justxor/c56eee6783636b73461c8cb3a77782ef to your computer and use it in GitHub Desktop.
list_ = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(list_)
# lambda function
lambda_list = list(map(lambda x: x * 2, list_))
# Map basically iterates every element
# in the list_ and returns the lambda
# function result
print(lambda_list)
# list comprehension
list_comp = [x * 2 for x in list_]
print(list_comp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment