в чём ошибка? import random
print("Welcome to the game: \ 'Rock, paper, scissors'")
print(">... The game will go againts the computer.")
print(">... The game consist of 3 rounds!")
print(" The winner is the one who has more points!")
print(" Use the big letters to slect: ")
print(" [r] - rock")
print(" [p] - paper")
print(" [s] - scissors")
user_score = 0
user_choise = 0
bot_score = 0
bot_choise = 0
print("-❤--❤--❤--❤--❤--❤-BEGIN OF THE GAME-❤--❤--❤--❤--❤--❤-")
for i in range(3):
print("Round №" + str(i+1) +"")
bot_choise = random.choices(["R","P","S"])
user_choise = input(">..Your choise:")
print(">...You" + user_choise + "x Bot: " + bot_choise + " - ", end=" ")
if user_choise == bot_choise:
print(">...Draw")
elif user_choise == "R":
if bot_choise == "S":
user_score = user_score + 1
print(">...Player won the round!")
else:
bot_score = bot_score + 1
print(">...The bot won the raound")
elif user_choise == "S":
if bot_choise == "P":
user_score = user_score + 1
print(">...Player won the round!")
else:
bot_score = bot_score + 1
print(">...The bot won the raound")
elif user_choise == "P":
if bot_choise == "R":
user_score = user_score + 1
print(">...Player won the round!")
else:
bot_score = bot_score + 1
print(">...The bot won the raound")
else:
print("ER%OR 404")
if user_score > bot_score:
print("Result of the game: The player won!")
elif bot_score > user_score:
print("Result of the game: The bot won!")
else:
print("Result of the game: Draw")
Код ошибки :
File "c:\Users\Student\урок\1.py", line 22, in
print(">...You" + user_choise + "x Bot: " + bot_choise + " - ", end=" ")
TypeError: can only concatenate str (not "list") to str
Вам нужно было просто конвертировать список в строчку
Объяснение:
Изменений код прикрепил
print(">...You", user_choise, "x Bot:", bot_choise, "-", end=" ")
Объяснение:
user_choise, bot_choise - целочисленные переменные. Нельзя использовать операцию сложение для разных типов.