Skip to content

Instantly share code, notes, and snippets.

@normanlmfung
Last active March 30, 2024 22:52
Show Gist options
  • Save normanlmfung/43267b625335ad0f95dace6e6fd60546 to your computer and use it in GitHub Desktop.
Save normanlmfung/43267b625335ad0f95dace6e6fd60546 to your computer and use it in GitHub Desktop.
python_syntax_map
nums = [ 1,2,3,4,5 ]
squares = []
for num in nums:
squares.append(num**2)
# instead of loop, use 'map'
squares = list(map(lambda num: num ** 2, nums))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment