Created
June 18, 2013 05:17
-
-
Save piyonishi/5802813 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
# インデックスつきループ | |
# listの場合enumerateを使う | |
sample_list = ['i', 'ro', 'ha', 'ni', 'ho', 'he', 'to'] | |
for i, v in enumerate(sample_list): | |
print(i, v) | |
# dictionaryで3.xの場合itemsを使う | |
# iteritemsは廃止 | |
sample_dictionary = {0:'i', 1:'ro', 2:'ha', 3:'ni', 4:'ho', 5:'he', 6:'to'} | |
for i, v in sample_dictionary.items(): | |
print(i, v) | |
# dictionaryで2.xの場合iteritemsを使う | |
for i, v in sample_dictionary.iteritems(): | |
print i, v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment