Skip to content

Instantly share code, notes, and snippets.

@ejcer
Created October 7, 2016 15:52
Show Gist options
  • Save ejcer/9614afecdb0acf77a86097dc77d88bc3 to your computer and use it in GitHub Desktop.
Save ejcer/9614afecdb0acf77a86097dc77d88bc3 to your computer and use it in GitHub Desktop.
#unpythonic code in idiom_tests_copy.py:
result = []
for i in range(10):
s = i ** 2
result.append(s)
print(sum(result))
#pythonic code that I was attempting to transform idiom_tests_copy.py into:
result = [i**2 for i in range(10)]
print(sum(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment