I followed the exact code done by the channel for a slot machine, and it doesnt work once i tried it in the beginning...
The code:
MAX_LINES = 3
MAX_BET = 100
MIN_BET = 1
def deposit():
while True:
amount = input("How much would you like to deposit?: $")
if amount.isdigit():
amount = int(amount)
if amount > 0:
break
else:
print("Amount must be greater than 0.")
else:
print("Please enter a number.")
return amount
def get_number_of_lines():
while True:
lines = input("How many lines would you like to bet on? (1-" + str(MAX_LINES) + "): ")
if lines.isdigit():
lines = int(lines)
if 1 <= lines <= MAX_LINES:
break
else:
print("Enter a valid number of lines")
else:
print("Please enter a number.")
return lines
def get_bet():
while True:
bet = input("How much would you like to bet on each line? $")
if bet.isdigit():
bet = int(bet)
if MIN_BET <= bet <= MAX_BET:
break
else:
print(f"Amount must be from ${MIN_BET} to ${MAX_BET}.")
else:
print("Please enter a number.")
return bet
def main():
balance = deposit()
lines = get_number_of_lines()
while True:
bet = get_bet()
total_bet = bet * lines
if total_bet > balance:
print(f"You do not have enough to bet that amount, your current balance is {balance}")
else:
break
print(f"You are betting ${bet} on {lines}. Total bet is ${total_bet}.")
main()
The problem is that the code is not responding to the while loop in the function of main (the def main() one)