擅长:python、mysql、java
<blockquote>
<p>But I only want it to jump to the else statement if all of the values does not equal!</p>
</blockquote>
<p>Python的<code>for</code>-<code>else</code>构造可以用来实现这一点:</p>
<pre><code>for item in dict:
if dict[item] == (500, 50, 200):
print('Yes')
break
else:
print('No')
</code></pre>
<p>有关进一步讨论,请参见<a href="https://stackoverflow.com/questions/9979970/why-does-python-use-else-after-for-and-while-loops">Why does python use 'else' after for and while loops?</a></p>
<p>但是,在这个特定的实例中,我根本不会使用显式循环:</p>
<pre><code>print ("Yes" if (500, 50, 200) in dict.values() else "No")
</code></pre>