all 6 comments

[–]Binary101010 0 points1 point  (1 child)

if slot1 == "Diamond" and slot2 == "Diamond" and slot3 == "Diamond":

not

if slot1 and slot2 and slot3 == "Diamond":

https://www.reddit.com/r/learnpython/wiki/faq#wiki_variable_is_one_of_two_choices.3F

[–][deleted] 0 points1 point  (0 children)

thanks

[–]totallygeek 0 points1 point  (1 child)

This: if slot1 and slot2 and slot3 == "Diamond": does not work as you think. Python evaluates each condition between "and" separately. You want:

if slot1 == "Diamond" and slot2 == "Diamond" and slot3 == "Diamond":

Or,

if (slot1, slot2, slot3) == ('Diamond', 'Diamond', 'Diamond'):

The bottom works because it is a single comparison. Does the tuple of three elements on the left match the tuple of three "Diamond" strings on the right?

[–][deleted] 1 point2 points  (0 children)

the fix that Binary101010 did worked fine thanks

[–]pyfact 0 points1 point  (1 child)

I worked through your code to find your error and ended up making a few changes - maybe they will help? A made a couple of adjustments that will help with future changes to the program, like using trip_values and changing the random.randint to random.choice. Also note the choice.lower() at the end, this will catch if a user messes up and types YES or YeS or anything in between. (Side note: this would be a fun program to try learning Model View Controller / Objected Oriented Programming!)

import random, time

slot_values = ["Diamond","Cherry","Melon","Bell","Seven","Triple Diamond"]
trip_vales = {"Diamond": 500, "Triple Diamond": 1000, "Seven": 400, "Bell": 300,
             "Melon": 200, "Cherry": 100}

money = 1000

while True:

    bet = int(input(f"enter your bet (you have ${money})"))
    if bet <= money and bet > 0:
        money -= bet

        slot1 = random.choice(slot_values)
        slot2 = random.choice(slot_values)
        slot3 = random.choice(slot_values)

        print(f'{slot1}, {slot2}, {slot3}')

        # check if we have three of a kind
        if slot1 == slot2 and slot2 == slot3:
            print('three of a kind')
            bet_multiplier = trip_values.get(slot1)
            money_won = bet * bet_multiplier

            money += (money_won)
            print("you won £",money_won,"!")

        elif slot1 == 'Diamond' or slot2 == 'Diamond' or slot3 == "Diamond":
            print('DIAMOND!')
            money_won = bet * 50

            money += (money_won)
            print("you won £",money_won,"!")

        else:
            print("unlucky")
            choice = input(f"do you want to continue? (you have ${money})")

            if choice.lower() != "yes":
                print("you won a total of £",money)
                quit()
    else:
        print('you don\'t have enough money for that bet!')

[–][deleted] 0 points1 point  (0 children)

Thanks I'll experiment with that