Answer the question
In order to leave comments, you need to log in
How to fix my BlackJack code in Python?
@bot.message_handler(content_types=['text']) # Ответ бота на текстовые команды
def send_text(message): # Функция отправки текста в ТГ
if message.text == "Играть":
def ochko(message):
koloda = [6,7,8,9,10,2,3,4,11] * 4
import random
random.shuffle(koloda)
bul = True
count = 0
dealercount = 0
newcard = koloda.pop()
startuser = koloda.pop() + koloda.pop()
startdealer = koloda.pop()
count += startuser
dealercount += startdealer
print(startdealer)
print(startuser)
def ochkoplay(message, count, dealercount):
while bul:
if message.text == "Добрать":
newcard = koloda.pop()
count+=newcard
dealercount += koloda.pop()
print(count)
if count > 21:
bot.send_message(message.chat.id, "Вы вытянули карту с номиналом " + str(newcard) + "\nВаш счёт - %a\nПеребор - вы проиграли" %(count), parse_mode='HTML', reply_markup=kb21)
break
elif count == 21:
bot.send_message(message.chat.id, "Эйс, 21!\nВы выиграли!\nСчёт дилера - %a" %(dealercount), parse_mode='HTML', reply_markup=kb21)
break
else:
bot.send_message(message.chat.id, "Вы вытянули карту с номиналом " + str(newcard) + "\nВаш счёт - %a" %(count), parse_mode='HTML', reply_markup=kb21)
if message.text == "Вскрыться":
print(" ")
sent = bot.send_message(message.chat.id, "Ваш cчёт: %a\nСчёт дилера: %a" %(count, dealercount), parse_mode='HTML', reply_markup=kb21)
bot.register_next_step_handler(sent, ochkoplay)
ochko(message, count, dealercount)
Answer the question
In order to leave comments, you need to log in
bot.register_next_step_handler(sent, ochkoplay )
ochkoplay - a function that expects input parameters
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question