Created
May 19, 2021 14:36
-
-
Save Alexpeain/79450782bd1e418d5d4f7cf9241b74df to your computer and use it in GitHub Desktop.
23.2. Map
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
#1.Using map, create a list assigned to the variable greeting_doubled that doubles each element in the list lst | |
lst = [["hi", "bye"], "hello", "goodbye", [9, 2], 4] | |
def cat (f): | |
return [f] | |
greeting_doubled = map ( cat , lst) | |
print(greeting_doubled) | |
greeting_doubled = map(lambda things : 2* things ,lst ) | |
print(greeting_doubled) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment