擅长:python、mysql、java
<p>你的代码基本上是好的,当你想要圆括号(用于函数/方法调用)时,你只是滥用了方括号(用于索引/查找)。<code>append</code>是<code>list</code>上的一个方法,因此需要用括号分隔参数,更改:</p>
<pre><code>letterList.append[letter]
underscoreList.append["_"]
</code></pre>
<p>收件人:</p>
^{pr2}$
<p>请注意,在这种特殊情况下,您可以简化很多,将循环(以及<code>list</code>的初始定义)分别转换为<code>list</code>和{<cd2>}乘法,只留下:</p>
<pre><code>import random
wordList = ["bird", "dog", "cat", "school", "computer"]
word = random.choice(wordList)
letterList = list(word) # Converts to list of characters directly
underscoreList = ['_'] * len(word) # Makes list of underscores of matching length
</code></pre>