<p><strong>首先</strong>你需要知道<a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries" rel="nofollow noreferrer">how python plays with dictionary</a>-你问的问题非常简单,因此人们投了反对票!你知道吗</p>
<p><strong>回答您的问题:</strong></p>
<p>您已经记住了下面的代码,并且正在为剩下的代码而奋斗。我将根据你的陈述相应地回答他们。你知道吗</p>
<pre><code>SCRABBLE_LETTER_VALUES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
letter = 'i'
</code></pre>
<p>在python中,为了获得对应键的值,它的工作方式类似于<code>dictionary[key]</code>,它给出了输出。你知道吗</p>
<p>所以对于你的问题,如果我们做<code>SCRABBLE_LETTER_VALUES[letter]</code>,它和做<code>SCRABBLE_LETTER_VALUES['i']</code>一样,其中<code>'i'</code>是关键,我们会得到<code>1</code>作为输出。你知道吗</p>
<p>因此对于<code>SCRABBLE_LETTER_VALUES[letter]</code>我们得到<code>1</code>作为输出!你知道吗</p>
<blockquote>
<p>I want to add the corresponding value to the variable score. So since letter is equal to i</p>
</blockquote>
<p>将相应的值赋给变量得分是<code>score = SCRABBLE_LETTER_VALUES[letter]</code></p>
<blockquote>
<p>then score should equal 1</p>
</blockquote>
<p>我们现在肯定地知道<code>score</code>的值是<code>1</code>。不是吗?你知道吗</p>
<p>因为<code>SCRABBLE_LETTER_VALUES[letter]</code>值是<code>1</code>,而<code>letter= 'i'</code>因此<code>score</code>是<code>1</code></p>