Тема: Программування Python
Привіт поясніть як переробити код щоб він працював і показував хто виграв а хто програв.
from tkinter import*
from random import*
carddeck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'] * 4
shuffle(carddeck)
text1 = ['Black Jack']
count1 = 0
count2 = 0
def take():
global count, carddeck
card = carddeck.pop()
if card == 'J' or card == 'Q' or card == 'K':
card = 10
if card == 'A':
card = 11
if count1 < 21:
if count1 < count2:
text2 = ['You have points' + str(count1) + 'The bot came out' + str(count2) + 'You lose..']
else:
text3 = ['You have points' + str(count1) + 'The bot came out' + str(count2) + 'You Win!']
def enough():
global count
if count1 == 21:
if count1 > count2:
text2 = ['You have points' + str(count1) + "You win!"]
elif count1 == count2:
text3 = ['Draw']
root=Tk()
root.title("BlackJack")
root.geometry("300x140")
text1 = Label(root, text = "Game stared!", fg='red')
text1.place(x = 100, y = 0)
text2 = Label(root, text = "You have zero points", fg='blue')
text2.place(x = 105, y = 50)
take_btn = Button(root, text = "Take the card", width=15, command=take).place(x=20, y=70)
enough_btn = Button(root, text = "Enough", width=15, command=enough).place(x=160, y=70)
text3=Label(root, text = "Result", fg="red").place(x=100, y=100)
root.mainloop()