I'm new to Python and I'm very open to any criticism and tips, it would help me a lot. I've also realized that changing the value I've assigned to 'Ace' still returns 10 and I can't find the root of the problem. I also tried interchanging the position of if player_card.value[0] == '10' or 'Jack' or 'Queen' or 'King': player_card.count = 10 with if player_card.value[0] == 'Ace': player_card.count = 11 and still no luck. I also tried using elif instead of just if's but as I expected, it didn't help. I haven't looked into other people's codes/videos in coding a blackjack game because I wanted to make it from scratch and to test my mastery on Python.
import random
import itertools as it
def player_card():
player_card.drawn_card = random.choice(deck.cards)
deck.cards.remove(player_card.drawn_card)
player_card.value = player_card.drawn_card.split()
if player_card.value[0] == '2':
player_card.count = 2
if player_card.value[0] == '3':
player_card.count = 3
if player_card.value[0] == '4':
player_card.count = 4
if player_card.value[0] == '5':
player_card.count = 5
if player_card.value[0] == '6':
player_card.count = 6
if player_card.value[0] == '7':
player_card.count = 7
if player_card.value[0] == '8':
player_card.count = 8
if player_card.value[0] == '9':
player_card.count = 9
if player_card.value[0] == 'Ace':
player_card.count = 11
if player_card.value[0] == '10' or 'Jack' or 'Queen' or 'King':
player_card.count = 10
#the dealer card funtion is just the same as the player card so I didn't bother placing it here
def first_phase():
player_card()
first_phase.player_count = player_card.count
print(f'Player was dealt the {player_card.drawn_card}')
dealer_card()
first_phase.dealer_count = dealer_card.count
print(f'Dealer deals himself a {dealer_card.drawn_card}, Dealer Count: {first_phase.dealer_count}')
player_card()
print(player_card.count)
print(player_card.value[0])
first_phase.player_count += player_card.count
print(f'Player was dealt the {player_card.drawn_card}, Player Count: {first_phase.player_count}')