Skip to content

Instantly share code, notes, and snippets.

@Alexpeain
Created May 19, 2021 14:36
Show Gist options
  • Save Alexpeain/79450782bd1e418d5d4f7cf9241b74df to your computer and use it in GitHub Desktop.
Save Alexpeain/79450782bd1e418d5d4f7cf9241b74df to your computer and use it in GitHub Desktop.
23.2. Map
#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