0

PYTHON: TypeError: bad operand type for unary +: 'str'

Hi guys, I am trying to make a text-based game in python where Player_1 decides what is in his sandwich and Player_2 must guess what is in the sandwich. However whenever I run the programme I get this error. Any ideas? Traceback (most recent call last): File "./Playground/file0.py", line 5, in <module> Guess=input(Player_2,+"guess what is in the sandwich") TypeError: bad operand type for unary +: 'str' This is my code... Player_1=input("Player_1, what is your name?: \n") Player_2=input("Player_2, what is your name?: \n") print("Welcome"+" "+Player_1+" "+Player_2) Ingredients=input(Player_1+","+" "+"what is in your sandwich?") Guess=input(Player_2,+"guess what is in the sandwich") if Guess==Ingredients: print("Correct"+" "+Player_2+"well done!") else: print("Incorrect!") Thanks for your time!

22nd Feb 2020, 6:08 PM
Cillian
Cillian - avatar
3 odpowiedzi
+ 2
Remove the ",": Guess = input(Player_2 + "guess what is in the sandwich?")
22nd Feb 2020, 6:13 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
I can see many errors. It would be good if you check it again. I can see many quotation marks which you have not closed and some commas at wrong place too.
22nd Feb 2020, 6:13 PM
Utkarsh Sharma
Utkarsh Sharma - avatar
0
Okay Thanks, I can see I have much to learn! XD
22nd Feb 2020, 6:31 PM
Cillian
Cillian - avatar