Getting Type error

This commit is contained in:
Stephen Deaton 2024-06-27 17:09:46 -04:00
parent 9aa6b06c24
commit 2c16341658

View File

@ -21,20 +21,18 @@ SYMBOL_VALUE = {
"D": 2 "D": 2
} }
def check_winings(columns: List, my_bet: int, my_lines: int):
def check_winings(columns, bet, lines, values):
winnings = 0 winnings = 0
winning_lines = [] winning_lines = []
for line in range(lines): for line in range(my_lines):
symbol = columns[0][line] symbol = columns[0][line]
for column in columns: for column in columns:
symbol_to_check = column[line] symbol_to_check = column[line]
if symbol != symbol_to_check: if symbol != symbol_to_check:
break break
else: else:
winnings += values[symbol] * bet winnings += SYMBOL_VALUE[symbol] * my_bet
winning_lines.append( +1) winning_lines.append(line + 1)
return winnings, winning_lines return winnings, winning_lines
@ -102,7 +100,7 @@ def get_bet() -> int:
print(" Error: Please enter a number") print(" Error: Please enter a number")
return bet return bet
def main(): def roll():
balance = deposit() balance = deposit()
lines = get_number_of_lines() lines = get_number_of_lines()
bet = -1 bet = -1
@ -116,12 +114,30 @@ def main():
if total_bet == 0: if total_bet == 0:
return return
print(f"You are betting ${bet} on {lines} lines. Total bet is equal to: ${total_bet} ") print(f"You are betting ${bet} on {lines} lines. Total bet is equal to: ${total_bet} ")
slots = get_slot_machine_spin() slots = get_slot_machine_spin()
print_slotmachine(slots) print_slotmachine(slots)
winnings, winning_lines = check_winings(slots, lines, bet, SYMBOL_VALUE) winnings, winning_lines = check_winings(slots, bet, lines)
print(f"You won ${winnings}.") print(f"You won ${winnings}.")
print(f"You won on lines:", *winning_lines) if len(winning_lines) > 0:
print(f"You won on line" + ("s" if len(winning_lines) > 1 else "") + ":", *winning_lines)
balance += winnings
else:
balance -= bet * lines
print(f"Your balance is now: ${balance}")
return winnings - total_bet
def main() -> int:
balance = deposit()
while True:
print(f"Current Balance is ${balance}")
answer = input("Press enter to play (q to quit).")
if answer == "q":
break
balance += roll(balance)
print(f"YOu left with ${balance}")
main() main()
print() print()
print("Thank you for playing!") print("Thank you for playing!")