擅长:python、mysql、java
<p>我从您的代码中猜测<code>statlist</code>是一个包含<code>stat</code>键和<code>stat value</code>值的字典。现在你有了一个列表,所以本质上你说的是“如果这个项目在列表中,请在它的末尾加上一个数字”(尽管不正确)。你知道吗</p>
<p>你要做的是给问题加上词典。第一部分,声明变量,并不完全必要,您可以这样完成:</p>
<pre><code>statlist = {'small guns' : 5, 'big guns' : 2, ...}
</code></pre>
<p>对于每个值。然后,要更改统计信息:</p>
<pre><code>if choice in statlist:
pointDeduction = input("How many points do you wish to add to %s? (Up to %s points)" %(choice, skillPoints))
if pointDeduction <= statlist[choice]:
statlist[choice] += pointDeduction
skillPoints -= pointDeduction
else:
print "You do not have that many points to distribute to %s." %(choice)
</code></pre>