I am working on a blackjack game to train myself. I am at the beginning. I have done all the game basically, but when the game ends, and I restart it, the numbers of the list, which are the cards, doesn't restore. I tried using copy and deepcopy, and saving it into another variable, but it won't work.
cards = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11]
saved_cards = copy.copy(cards)
def start(x, y):
# Dealer
cards = saved_cards
index1 = int(random.choice(cards)) # Pesca le carte
index2 = int(random.choice(cards))
y = y + index1 + index2
cards.remove(index1) # Rimuove le carte dal mazzo
cards.remove(index2)
#Player
index1 = int(random.choice(cards))
index2 = int(random.choice(cards))
x = x + index1 + index2
if index1 == 9 or 10 and index2 == 1:
index2 = 11
cards.remove(index1)
cards.remove(index2)
def end():
again = input("Vuoi rigiocare? ")
if again in ["S", "s"]:
start(x = 0, y = 0)
elif again in ["N", "n"]:
print("Grazie per aver giocato!")
return