Created
July 7, 2013 10:24
-
-
Save shigemk2/5943037 to your computer and use it in GitHub Desktop.
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
# -*- coding: euc-jp -*-" | |
# リストを操作するコードをループごとにインタプリタ上で処理している | |
# カウンタの操作もループごとにインタプリタ上で処理する必要がある | |
size = 10 | |
L = [] | |
i = 0 | |
while i < size: | |
if i % 2 == 0 and i != 4: | |
L.append(i) | |
i += 1 | |
print L # [0, 2, 6, 8] | |
# そこでリスト内包表記 | |
print [i for i in range(10) if i % 2 == 0 and i != 4] # [0, 2, 6, 8] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment