wrote a blackjack game in python , would like you get notes on it I started learning python online and I wrote a blackjack game as my first little project.
I would like to get some review on it if possible. (how to make it better , simpler , etc)

from random import choice
cards = ['A', 2, 3, 4, 5, 6, 7, 8 , 9,'J','Q','K']*4

def get_card(name):
    card = choice(cards)
    cards.remove(card)
    print(f'{name} got {card}')
    return card

def hand(cards):
    global dealer_total
    dealer_total = 0
    dealer_card = convert(get_card('The dealer'),dealer_total)
    dealer_total += dealer_card
    total = 0
    card = convert(get_card('You'),total)
    total += card
    card = convert(get_card('You'),total)
    total += card
    if total == 21:
        print('Blackjack! You Won!')
        another_game()
    check_total(total)

def convert(card,total):
    if card == 'A':
        if total &gt; 10:
            card = 1
        else: card = 11
    if card in ['K','Q','J']:
        card = 10
    return card

def check_total(total):
    if total == 21:
        print(f'You stand on a total of {total}. Lets see what the dealer gets:')
        dealer_hand(total,dealer_total)
    elif total &gt; 21:
        print(f'You stand on a total of {total}. You lost!')
        another_game()
    else:
        another_card(total)

def another_game():
    another_game = input('Would you like to play again ?').lower()
    if another_game == 'yes':
        cards = ['A', 2, 3, 4, 5, 6, 7, 8 , 9,'J','Q','K']*4
        hand(cards)
    elif another_game == 'no':
        print('Goodbye !')
        quit()
    else:
        raise ValueError('You entered the wrong value')
        another_game()

def another_card(total):
    another = input(f'You stand on a total of {total}. Would you like another card ? (Yes/No)').lower()
    if another == 'yes':
        card = convert(get_card('You'),total)
        total += card
        check_total(total)
    elif another == 'no':
        print('OK , lets see what the dealer gets')
        print(f'Before fliiping the cards , the dealer stands on a total of {dealer_total}')
        dealer_hand(total,dealer_total)
    else:
        raise ValueError('You entered the wrong value')
        another_card(total)

def dealer_hand(total,dealer_total):
    card = convert(get_card('The dealer'),dealer_total)
    dealer_total += card
    if dealer_total &gt; 21:
        print(f"Dealer's total is {dealer_total}. You won ! ")
        another_game()
    elif dealer_total &gt; 16:
        print(f'Dealers total is {dealer_total}.The dealer must stand.')
        who_won(total,dealer_total)
    elif dealer_total &lt; 17:
        print(f"Dealer's total is {dealer_total}. He must take another card.")
        dealer_hand(total,dealer_total)

def who_won(my_total,dealer_total):
    print(f'Your total is {my_total} , The dealers total is {dealer_total}')
    if my_total &gt; dealer_total:
        print('You won !')
    elif my_total &lt; dealer_total:
        print('You lost !')
    else:
        print('Its a tie !')
    another_game()


print('Hello !')
hand(cards)


I highly appreciate it , thank you !!
Naming things

Try to give proper names to things, such that they follow the usual conventions, are concise, unambiguous and to the point. There are a few things I would change:


Rename cards to deck, to signify that it isn't just a random bunch of cards, but the actual deck you are drawing from.
The function hand() is quite misnamed, it's not about managing just one hand of cards, but rather it implements the whole game. So perhaps play_blackjack() would be better?
The function convert() has a very generic name, that doesn't tell anything about what it is converting from or to. It would be better named convert_card_to_value().


In general, variables describe things, so their names should usually be a noun, whereas functions describe actions, so they should be verbs.

Try to reorganize the code into classes

Classes make it easier to organize your code. I can think of at least three classes that you should make: Card, Deck and Hand.

A Card is quite simple, it just is the color and number of the card, and has a member function to convert it to a value.

A Deck is a collection of cards, with member functions like shuffle(), draw() and so on.

A Hand is also a collection of cards, but has member functions add() and get_value(). The latter is important: you can't just add values of cards together to get the total value of a hand. Think about drawing an ace, 9, king in that order. Your current code converts card values the moment they are drawn, and only checks aces against the total so far. So your method would count this as 11 + 9 + 10 = 30, whereas the correct value is 1 + 9 + 10 = 20.

Avoid infinite recursion

Your code recursively calls itself indefinitely. While this might seem harmless at first, the problem is that you are using more and more stack space, until after enough games played you get a stack overflow. The proper way to deal with this is to structure some parts of your code as loops. For example, you want to have a function to play one game of blackjack, and that function should be called in a loop like so:

def another_game():
     while True:
          answer = input('Would you like to play again?').lower()
          if answer == 'yes':
              return True
          elif answer == 'no':
              return False
          else
              print('Please enter yes or no.')

...

print('Hello!')

while True:
    play_game();
    if not another_game():
        break

print('Goodbye!')
```