2017-04-13 4 views
1

Ich versuche, ein textbasiertes Adventure-Spiel zu machen, und ich bekomme diesen Fehler: "0 bis 1 Positionsargumente aber 2 wurden gegeben." Ich bin mir nicht sicher, was es bedeutet oder wie es zu beheben ist. Kann mir jemand das Problem erklären? Vielen Dank!raw_input_wrapper() nimmt von 0 bis 1 Positionsargumente, aber 2 wurden Python 3.5 gegeben

########################################################## 
##farm game 
########################################################## 


player_name = input("What's your name? ") 
print ("Hello {}".format(player_name)) 

print ("You wake up to the sound of your mother calling from the kitchen: 
     {}" .format(player_name), ", wake up! I need your help in the kitchen!") 
ch1 = str(input("Will you go downstairs? ")) 

# kitchen 
if ch1 in ['y', 'Y', 'Yes', 'YES', 'yes']: 
    print("You go downstairs.") 
    ch2 = str(input("Your mother is in front of the oven, preparing to make 
       a loaf of bread. She turns to look at you and says: {}" 
       .format(player_name), ", I need three eggs. Please go fetch 
       the eggs from the barn.")) 
if ch2 in ['y', 'Y', 'Yes', 'YES', 'yes']: 
    print("You leave the kitchen and enter the large back yard. You are in 
     a fenced in area. Three pigs are rooting around in the fresh spring 
     grass, snorting and snuffling. At the end of the yard is the barn, 
     where the cows and horses live. To your right is the kitchen coop. 
     You can hear the soft clucking of chickens from inside.") 

# no kitchen 
else: 
    print("You look around the room.") 
+0

Mein ob und Druckanweisungen sind eingerückt, aber ich habe nicht kopieren füge es hier so ein. Also ich denke nicht, dass es ein Syntaxproblem ist. – Jane

+0

Ich habe die Formatierung für dich aufgeräumt. – gregb212

Antwort

1

Sie übergeben zu viele Argumente in input(). Siehe folgende Beispiele:

>>> x = input() 
hello world 
>>> print(x) 
hello world 


>>> x = input("Say hello: ") 
Say hello: hello world 
>>> print(x) 
hello world 


>>> x = input("first argument", "second argument") 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
TypeError: input expected at most 1 arguments, got 2 

Um den Spielernamen auf Ihre Eingabe hinzufügen, verschieben die .format bis zum Ende des Strings:

ch2 = input("Your mother is in front of the oven, preparing to make a loaf of bread. She turns to look at you and says: {} , I need three eggs. Please go fetch the eggs from the barn.".format(player_name))) 
+0

Das hat das Problem behoben! Vielen Dank. – Jane

Verwandte Themen