import random
from random import randint
print("Welcome to Brandon's Maze Game",
"You have to get 10 shields or find the exit to win",
"Good Luck :D")
counter = 0
shields = 3
fate = randint(1,2)
direction = input("You have come to a stop, do you want to turn Left(L) or Right(R)? ")
if direction == "L":
if fate == 1:
shields += 3
counter += 1
direction = input("You came across a chest, you now have ",shields, "! What way do you want to go next? Left(L) or Right(R)? ")
if fate == 2:
shields -= 1
counter += 1
direction = input("Uh oh, you got attacked and lost a shield, you now have ",shields," shields. Do you want to go Left(L) or Right(R)? ")
if direction == "R":
if fate == 1:
shields += 3
counter += 1
direction = input("You came across a chest, you now have ",shields, "! What way do you want to go next? Left(L) or Right(R)? ")
if fate == 2:
shields -= 1
counter += 1
direction = input("Uh oh, you got attacked and lost a shield, you now have ",shields," shields. Do you want to go Left(L) or Right(R)? ")
if counter == 10:
print("Congratulations, you made it to the end with ",shields," shields.")
我正在做一個迷宮遊戲,用戶可以選擇左(「L」)或右(「R」),然後該程序使選擇是否讓玩家找到胸部或受到攻擊。當用戶發現聊天時他們獲得+3盾牌,如果他們受到攻擊,他們將失去1盾牌。 當我輸入「L」或「R」它說:在線19 TypeError:輸入預計最多1個參數,得到3. 不知道發生了什麼,因爲我只輸入1值嗎?, 任何幫助表示。迷宮遊戲 - 輸入預計最多1個參數,得到3
不是100%肯定你的意思,我很新的蟒蛇,但我會盡量採用哪些你說,謝謝。 foo和buzz在哪裏出現?我很困惑 – MiniMiloe
@BrandonFarmiloe當你調用'input'函數時,你給它三個參數。 「輸入」最多隻能有一個參數。爲了舉例,我選擇了短字符串,而不是複製你的字符串。 – timgeb