L
L
leon -----2021-06-06 21:11:59
Python
leon -----, 2021-06-06 21:11:59

The program crashes without error. What to do?

Wrote a game of rock, paper, scissors. I launch, and it crashes as soon as I chose stone, scissors or paper. WITHOUT ERROR!
! This all happened as I added the account !
c1 - human
c2 - bot
Here is the code:

import random
a = ['камень', 'ножницы', 'бумага']

c1 = 0
c2 = 0

x = "да"
while x == "да":
  b = random.choice(a)
  u = input("камень, ножницы или бумага?(Чтобы обнулить счет наберите обнл):")
  if b == u:
    print("ничья!")
  if b == "ножницы" and u == "камень":
    print("Бот выбрал ножницы. Вы победили!")
    c1 += 1

  if b == "бумага" and u == "камень":
    print("Бот выбрал бумагу. Вы проиграли!")
    c2 += 1

  if b == "камень" and u == "ножницы":
    print("Бот выбрал камень. Вы проиграли!")
    c2 += 1

  if b == "камень" and u == "бумага":
    print("Бот выбрал камень. Вы победили!")
    c1 += 1

  if b == "бумага" and u == "ножницы":
    print("Бот выбрал бумагу. Вы победили!")
    c1 += 1

  if b == "ножницы" and u == "бумага":
    print("Бот выбрал ножницы. Вы проиграли!")
    c2 += 1
  if u == "обнл":
    print("Бот:" + c2 + "  Вы:" + c1)
    c1 = 0
    c2 = 0
  if c2 > c1:
    arg = " в пользу Бота "
  if c1 > c1:
    arg = " в пользу Вас "
  if c2 == c1:
    arg = " ничья "

  x = input("Хотите продолжить? счет:" + c2 + "-" + c1 + arg + "(да чтобы продолжить!):")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2021-06-06
@leon1000

It's not true that it crashes without error.
The interpreter tells you clearly:

x = input("Хотите продолжить? счет:" + c2 + "-" +c1 + arg + "(да чтобы продолжить!):")
TypeError: can only concatenate str (not "int") to str

What is so complicated here that it is necessary to ask on the forum? Have you tried opening the textbook?
x = input("Хотите продолжить? счет:" + str(c2) + "-" + str(c1) + arg + "(да чтобы продолжить!):")

I think your next question will be about the incorrect calculation of the result. I ask in advance.
This:
if c1 > c1:
    arg = " в пользу Вас "

what do you think it should mean?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question