擅长:python、mysql、java
<p><strong>使用<code>.lower()</code>string方法将输入返回的字符串转换为小写。</strong></p>
<p>也就是说</p>
<pre><code>fav_color = 'red'
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = input('What's Carlos' favorite color? ').lower()
guess_count += 1
if guess == fav_color:
print("You win!")
break
</code></pre>
<hr/>
<p>为了让您了解<code>.lower()</code>方法的工作原理,我将提供一些示例:</p>
<pre><code>>>> 'Hello'.lower()
'hello'
>>> 'hello'.lower()
'hello'
>>> 'HELLO'.lower()
'hello'
>>> 'HeLLo HOW aRe YOu ToDAY?'.lower()
'hello how are you today?'
</code></pre>