擅长:python、mysql、java
<p>你的代码是好的(虽然不是最好的,即使没有使用你提到的方法),但你有几个错别字:)这就是你所拥有的:</p>
<pre><code>for ch in character:
for ch in lowerLetters:
lowerCount += 1
for ch in upperLetters:
upperCount += 1
for ch in digits:
digitCount += 1
else:
nonAlphaCount += 1
</code></pre>
<p>这是你想输入的:</p>
<pre><code>for ch in character:
if ch in lowerLetters:
lowerCount += 1
elif ch in upperLetters:
upperCount += 1
elif ch in digits:
digitCount += 1
else:
nonAlphaCount += 1
</code></pre>