Skip to content

Instantly share code, notes, and snippets.

@blubberdiblub
Created May 27, 2017 05:54
Show Gist options
  • Save blubberdiblub/63f8eb18d9e01ff477d66e3507c85869 to your computer and use it in GitHub Desktop.
Save blubberdiblub/63f8eb18d9e01ff477d66e3507c85869 to your computer and use it in GitHub Desktop.
Explaining list comprehension
new_list = [do_something_with(x) for x in old_list]
# is basically short for
new_list = []
for x in old_list:
new_list.append(do_something_with(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment