擅长:python、mysql、java
<p>另一种使用<code>while</code>的方法是模拟第一个字符的pop。当字符串的“truthiness”变为false且没有其他要处理的字符时,while循环终止:</p>
<pre><code>secret_word = "python"
correct_word = "yo"
while secret_word:
ch=secret_word[0]
secret_word=secret_word[1:]
if ch in correct_word:
print(ch,end=" ")
else:
print('_',end=" ")
</code></pre>
<p>或者,你可以使用一个带有LH-pop的列表:</p>
^{pr2}$