Created
June 1, 2022 10:05
-
-
Save justxor/c56eee6783636b73461c8cb3a77782ef to your computer and use it in GitHub Desktop.
This file contains 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
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