Skip to content

Instantly share code, notes, and snippets.

@emcenrue emcenrue/idioms.py

Created Oct 7, 2016
Embed
What would you like to do?
#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
You can’t perform that action at this time.