Trying to score a hand of blackjack in this python code but myloop is consistently outputting (13,1) which makes me think thatsomething is wrong with my loop.
Could someone help me with this code?:
import random
cards = [random.randint(1,13) for i in range(0,2)]
#initialize hand with two random cards
def get_card():
#this function will randomly return a card with the value between 1and 13
return random.randint(1,13)
def score(cards):
stand_on_value = 0
soft_ace = 0
for i in range(len(cards)):
if i == 1:
stand_on_value += 11
soft_ace = 1
# i += 1
if i < 10:
stand_on_value += i
if i >= 10 and i != 1:
stand_on_value += 10
else:
if i == 1:
stand_on_value += 1
return (stand_on_value, soft_ace)
if sum(cards) < 17:
stand_on_soft = False
elif sum(cards) >= 17:
stand_on_soft = True
print(score(cards))