-2
我在業餘時間自學python。我只在這裏待了幾天,所以在練習中我一直在使用各種raw_input線。目前,我正在嘗試爲朋友嘗試一個簡短的文字冒險。我打了一個街區,其中一部分詢問用戶是否想進村。如果他們選擇進入,一切都會正常工作,但如果他們選擇不這樣做,我需要它跳過村子內部發生的所有對話和投入。如何讓它跳轉到頁面下方的輸入?python中的分支對話
這是很基本的,但在這裏:
name = raw_input("What is your name adventurer? ")
where = raw_input("You are in a magical forest, you can go North or East, which
way do you go?")
if where.lower() == "north":
troll = raw_input("You encounter a troll, what do you do? Attack or flee? ")
else:
print("You encounter a dragon, you are dead, GAME OVER")
if troll.lower() == "attack":
print ("You have no weapon, that was a bad choice, you are dead, GAME OVER")
else:
flee = raw_input("You flee further North, you encounter a village, do you
enter or continue? ")
if flee.lower() == "enter":
army = raw_input("As you enter the village, a knight hands you a sword,
assuming you are there to join the army. Join him or leave the village? ")
else:
print ("You ignore the village and continue down the road.") #jump from here
if army.lower() == "join":
print ("You head off to war and are killed almost instantly because you are an
untrained fool")
else:
print ("You are kicked out of the village")
dark = raw_input("It is getting dark, do you continue or seek shelter") #to here
if dark.lower() == "continue":
print ("You are attacked by vampires and killed, GAME OVER")
else:
caves = raw_input("You find two caves, do you pick cave one which is pitch
black, or two which has light coming from it? ")
if caves.lower() == "one":
print ("You enter the cave, light a small fire, and sleep for the night.")
else:
print ("You enter the cave, there are bandits inside, you are murdered, GAME OVER")
我想第一粗線後跳下來暗。如果發現任何可以修復或改善的東西,請說出來。所有的批評都是受歡迎的。
請[edit](http://stackoverflow.com/posts/33811111/edit)你的問題和[格式化代碼](http://meta.stackoverflow.com/a/251362/1555990)。 – That1Guy
FWIW,格式化的部分原因是我們可以將您的完整代碼剪切並粘貼到編輯器中並自行運行。 –