<p>在<code>print("you dont have that many cards!")</code>我希望while循环从</p>
<pre><code>print("how many cards in heap no:", n, end="")
</code></pre>
<p>而不是打破。怎么能做到?</p>
<pre><code>y = []
def cardHeaps():
global cards
n = 1
while int(cards) > 0:
print("how many cards in heap no:", n, end="")
x = int(input("? "))
cards = int(cards)
if x > cards:
print("you dont have that many cards!")
break
y.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(x)
cards -= int(x)
print(cards, " cards left")
n += 1
if cards <= 0:
print("out of cards!")
break
</code></pre>