Ok so im making a rocks paper scissors game using python and I keep getting this error "TypeError: can only concatenate str (not "int") to str" and idk how to fix it. I have put the problem section of code and I hope someone else can see the error that I dont.while player == False:
#set player to True
23 print("Computer: " + computerscore + "\nPlayer: " + playerscore + "\n")
player = input("Rock, Paper, Scissors? ")
if player == computer:
print("Tie!")
elif player == "Rock":
if computer == "Paper":
print("You lose!", computer, "covers", player)
computerscore += 1
else:
print("You win!", player, "smashes", computer)
playerscore += 1
elif player == "Paper":
if computer == "Scissors":
print("You lose!", computer, "cut", player)
computerscore += 1
else:
print("You win!", player, "covers", computer)
playerscore += 1
elif player == "Scissors":
if computer == "Rock":
print("You lose...", computer, "smashes", player)
computerscore += 1
else:
print("You win!", player, "cut", computer)
playerscore = 1
else:
print("That's not a valid play. Check your spelling!")
The main problem is in line 23 thx
2 answers
while player == False:
#set player to True
23 print("Computer: " + computerscore + "\nPlayer: " + str(playerscore) + "\n")
player = input("Rock, Paper, Scissors? ")
if player == computer:
print("Tie!")
elif player == "Rock":
if computer == "Paper":
print("You lose!", computer, "covers", player)
computerscore += 1
else:
print("You win!", player, "smashes", computer)
playerscore += 1
elif player == "Paper":
if computer == "Scissors":
print("You lose!", computer, "cut", player)
computerscore += 1
else:
print("You win!", player, "covers", computer)
playerscore += 1
elif player == "Scissors":
if computer == "Rock":
print("You lose...", computer, "smashes", player)
computerscore += 1
else:
print("You win!", player, "cut", computer)
playerscore = 1
else:
print("That's not a valid play. Check your spelling!")