At print("you dont have that many cards!")
i want the while loop to start over from
print("how many cards in heap no:", n, end="")
instead of breaking. How can this be done?
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.append(x)
cards -= int(x)
print(cards, " cards left")
n += 开发者_如何学Python1
if cards <= 0:
print("out of cards!")
break
You have to use continue
instead of break
.
Python docs on continue
Use continue
instead of break
.
精彩评论