Joelinton
Joelinton

Reputation: 71

Project Slot Machine in Python

I am creating a slot machine using python and i don't have any idea how to print the slot machine but i want to print the slot machine from spin_slot_machine(symbols) there i have nine letters from symbol_count who were randomly chosen. For example if this is output from parameter columns of spin_slot_machine(symbols)-->['A', 'B', 'E', 'A', 'C', 'B', 'C', 'F', 'B'] i want to make like that like this ex:

enter image description here

import random 
MAX_VALUE = 100
MIN_VALUE = 1
ROWS = 3
COLUMNS = 3

symbols_count = {
    "A":2,
    "B":4,
    "C":3,
    "E":3,
    "F":2
}

def spin_slot_machine(symbols):
    all_symbols = []
    columns = []
    length_of_spin = 9
    for symbol,symbol_count in symbols.items():
        for i in range(symbol_count):
            all_symbols.append(symbol)
    for i in range(length_of_spin):
        get_random = random.choice(all_symbols)
        columns.append(get_random)
    return columns 
def print_slot_machine(columns):
    pass




        





def deposit():
    while True:
        deposit_money = input("How much money would you like to deposit?: $")
        if deposit_money.isdigit():
            deposit_money = int(deposit_money)
            if deposit_money > 0:
                break
            else:
                print("You should deposit more than 0$")
        print("Enter a digit")
    return deposit_money 
def bet_on_lines():
    while True:
        lines = input("On how many lines would you like to bet(1-3)?: ")
        if lines.isdigit():
            lines = int(lines)
            if lines >= 1 and lines <= 3:
                break
            else:
                print("Number of lines should be between 1-3")
        print("Enter a number of lines")
    return lines


def get_bet():
    while True:
        bet = input("How much money would you like to bet(1$-100$): ")
        if bet.isdigit():
            bet = int(bet)
            if bet <= MAX_VALUE and bet >= MIN_VALUE:
                break
            else:
                print("Money should be between 1-100$")
        else:
            print("Enter a digit")
    return bet 


def main():
    balance = deposit()
    lines_number = bet_on_lines()
    while True:
        bet_money = get_bet()
        total_bet = bet_money * lines_number 
        if total_bet > balance:
            print(f"Your balance is {balance}$.Balance shoudn't be less than betting money , bet less!")
        else:
            break
    print(f"You are betting {total_bet}$ on {lines_number} lines.")
    slot_machine = spin_slot_machine(symbols_count)
    print_slot_machine(slot_machine)

main()

        
        

Upvotes: -1

Views: 386

Answers (1)

Ged0jzn4
Ged0jzn4

Reputation: 80

If you just need to print them you can use something like this:

symbols = ['A', 'B', 'E', 'A', 'C', 'B', 'C', 'F', 'B']
print(' | '.join(symbols[0:3]))
print(' | '.join(symbols[3:6]))
print(' | '.join(symbols[6:9]))

It will give you what you wanted

Upvotes: 3

Related Questions