Last active
August 29, 2015 14:20
-
-
Save sincerefly/05f70ee6d5d330fad455 to your computer and use it in GitHub Desktop.
一个通过for...in...if...生成列表的例子
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = range(1,11) | |
b = range(1,10) | |
c = sum([item for item in a if item in b]) | |
print c | |
# result: 45 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment