@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 2366 / 12833)
word = 'letters'
letter_counts = {letter: word.count(letter) for letter in word}
print(letter_counts)
結果
{'s': 1, 'r': 1, 'e': 2, 'l': 1, 't': 2}
Pythonのdictionary comprehensions。
We are running a loop over each of the seven letters in the string 'letters'
意訳「7文字のそれぞれに対して、string 'letters'の走査を行う」
これを自分で英訳できるか微妙だ。overがeach of the にかかるようには自分では思いつかない。
We are runnig a loop for each of the seven letters in the string 'letters' over the string.
だろうか。冗長な気もする。
(追記 2017/03/13) over each of theの他の例
how to use the method we used to cycle over each of the menu links.