So i am a fairly new python user and i'm trying to make a game of rock paper scissors where you can either play against the AI or a simulation vs 2 real people (local gamee) but i keep getting this error:
TypeError: can only concatenate str (not "tuple") to str
Here's the line(s) of code where the problem occured:
print("Hello" User1 "and" User2 "please enter 2 again")
print(User1 " played " x)
print(User2 " played " y)
Here is a link to the entire code: https://i.stack.imgur.com/XKzVA.png Any help will be highly appreciated.
CodePudding user response:
You've initialized your user names as empty tuples here:
User1 = ()
User2 = ()
In your print statement, you attempt to concatenate a string with that tuple:
print("Hello" User1 "and" User2 "please enter 2 again")
Python does not define an addition between a tuple and a string, so it throws a Type Error. I'd recommend defining your user names as empty strings until you decide how to handle their entry into your program.