Ich mache gerade ein Text-Spiel, aber ein Teil meines Spiels wird nicht funktionieren, und ich kann nicht herausfinden, warum. Dies ist die Codierung:Bad Unary Operand anscheinend
c1pp1 = ["Joe", "Frank", "Annie"]
while cp_ptt < 3:
s= input()
#FIX THIS!!
c1pp = input(n/ + ": Who should I talk to first?\nYour options are:\n" +\
c1pp1[0] + ", an ex-policeman\n" + c1pp1[1] + ", a carpenter\n" +\
c1pp1[2] + ", an architect\n")
Das Resultat, das ich bekommen ist:
Traceback (most recent call last):
File "N:\MyWork\Year 9\Other\Random\Making a text game out of song lyrics\No.1;
Phantom Thief F's Scenario ~Mystery of the Missing Diamond~.py", line 103,
in <module>
c1pp = input(n/ + ": Who should I talk to first?\nYour options are:\n" + c1pp1[0] + ", an ex-policeman\n" + c1pp1[1] + ", a carpenter\n" + c1pp1[2] + ", an architect\n")
TypeError: bad operand type for unary +: 'str'
Kann jemand bitte sagen Sie mir, was mit meinem Code falsch?
Ist das 'n /' ein Tippfehler? Es sieht eindeutig so aus, als wäre das das Problem. Was versuchst du damit zu tun? –
@CarlesMitjans Der Fehler wäre 'NameError: Name 'n' ist nicht definiert. – DyZ
Die Frage ist: Warum ist das "n" da? Ist das eine Variable oder haben Sie versucht, einen Zeilenvorschub zu drucken? –