Question: Keep getting the error: print ( Enter a name for player + ( i + 1 ) + : ) TypeError: can

Keep getting the error:
print("Enter a name for player" +(i +1)+":")
TypeError: can only concatenate str (not "int") to str
Need help avoiding this error throughout all this code:
import random
random.seed() #Prepare random number generator
newTeams ="y"
playerName =""
i =0
numPlayers =0
print("Enter the number of players:")
numPlayers = int(input())
playerList =[""]*(numPlayers)
while i < numPlayers:
print("Enter a name for player" +(i +1)+":")
playerName = input()
playerList[i]= playerName
i = i +1
print("Total players entered:" + numPlayers)
while newTeams =="y":
court =1
sittingOut =""
for i in range(0, numPlayers -1+1,1):
j = int(random.random()*(numPlayers -1))
temp = playerList[i]
playerList[i]= playerList[j]
playerList[j]= temp
for i in range(0, numPlayers -1+4,4):
if numPlayers - i <4:
print("Player sitting out.")
print("--------------")
k = numPlayers -1
while k >= i:
sittingOut = sittingOut + playerList[k]+""
k = k -1
print(sittingOut)
else:
print("Players on court" + court +":")
print("-------------")
print(playerList[i]+" & "+ playerList[i +1]+" vs."+ playerList[i +2]+" & "+ playerList[i +3])
court = court +1
print("create new teams (y or n)?")
newTeams = input()
while newTeams !="y" and newTeams !="n":
print("Error. Create New teams (y or n)?")
newTeams = input()
print("Goodbye!")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!