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 += 1
if cards <= 0:
print("out of cards!")
break
You have to use continue
instead of break
.
Python docs on continue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With