#🔒 error in slot machine code again...
11 messages · Page 1 of 1 (latest)
@winged thicket
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
import random
def spin_row():
symbols = [':cherries:', ':watermelon:', ':lemon:', ':bell:', '7️']
return [random.choice(symbols) for _ in range(3)]
def print_row(row):
print("─────────────")
print(f'│{" │ ".join(row)}│')
print("─────────────")
def get_payout(row, bet):
if row[0] == row[1] == row[2]:
if row[0] == ':cherries:':
return bet * 3
elif row[0] == ':watermelon:':
return bet * 4
elif row[0] == ':lemon:':
return bet * 5
elif row[0] == ':bell:':
return bet * 10
elif row[0] == '7️':
return bet * 20
return 0
def main():
balance = 100
print("**************************")
print("Python Slot'a Hoş Geldin! ")
print("Semboller: :cherries: :watermelon: :lemon: :bell: :seven:")
print("**************************")
while balance > 0:
print(f'Kalan bakiye: ${balance}')
bet = input("Kullanacağınız miktarı giriniz: ")
if not bet.isdigit():
print("Lütfen bir sayı giriniz")
continue
bet = int(bet)
if bet > balance:
print("Yetersiz bakiye")
continue
if bet <= 0:
print("0'dan yüksek bir miktarda para kullanabilirsiniz")
continue
balance -= bet
row = spin_row()
print("Dönüyor...\n")
print_row(row)
payout = get_payout(row, bet)
if payout > 0:
print(f'${payout} Kazandın!')
elif row[0] == row[1] == row[2]:
if row[0] == ':seven:':
print("JACKPOT!")
else:
print("Kaybettin!")
balance += payout
if __name__ == '__main__':
main()
elif row[0] == row[1] == row[2]:
if row[0] == '7️⃣':
print("JACKPOT!")
part
didnt
work
how can I make it work
It looks like you're trying to compare the emoji variation selector for the number 7. This character is in your code on line 5, and 26. I have a feeling that using this character variation is causing the issues you're coming across. Try converting them both to :seven: and see if this issue still persists
@winged thicket
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.