<p>有没有可能在同一理解中检查列表中数字的总和,然后再进行一次,除非总和超过50?在</p>
<pre><code> k = input("input digits separated by spaces:")
try:
[int(i) for i in k.split()]
except ValueError:
print("input only digits")
</code></pre>
<p>最重要的是不要用两个except块来构造它,而是尽可能简单地确保列表的和不超过50个。在</p>