我很新的編程。我試圖做一個簡單的冒險遊戲,但我已經堅持試圖通過第一個功能。這是我到目前爲止的代碼:給出提示無法獲得更多的功能在初學Python代碼運行
def find_shelter():
print "Your crew needs to find shelter for the first night.\n"
print "Do you choose....\n"
print "The cave, it is near the water. You will be safe from wind, but there may be animals inside the cave.\n"
print "The beach, it is very comfortable. You can see boats, but we will be exposed to weather.\n"
print "The jungle, it has many trees. You will be safe from storms. However, there are many animals.\n"
print "The mountain, it is very high. You will be safe from the jungle animals, but you may fall off the mountain.\n"
choice = raw_input("Select A for cave, B for beach, C for jungle, or D for mountain. ")
return choice
def oh_no_cave():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "There was a flood in the cave, one person drowned and is dead."
crew = crew - 1
print "There are now %s people left in your crew.", crew
return crew
def oh_no_beach():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "The storm rained on you. One person was struck by lightening and is dead."
crew = crew - 1
print "There are now %s people left in your crew.", crew
return crew
def oh_no_jungle():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "But, you were safe in the jungle from the storm. Everyone is ok."
print "There are still %s people left in your crew.", crew
def oh_no_mountain():
print "OH NO! There was a very big storm in the night! It rained and the wind was very strong."
print "You all get very wet on the mountain, but everyone is ok."
print "There are still %s people left in your crew.", crew
choice = []
print "You are going on a cruise with your family and friends.\n"
crew = raw_input("Enter the number of people on the cruise, must be at least four: \n")
print "Oh no! Your crew has just shipwrecked on a desolate island."
print "All food and supplies were lost at sea, and the captain has died too. :("
print "On the island there is a beach, a river, a jungle, a mountain, and a cave."
if crew != 0:
find_shelter()
if choice == "a":
oh_no_cave()
elif choice == "b":
oh_no_beach()
elif choice == "c":
oh_no_jungle()
elif choice == "d":
oh_no_mountain()
else:
print "OH NO! Everyone in your crew has died! It's all over...."
print "Completely over."
後供用戶選擇A,B,C,d,什麼都不會發生用戶作出選擇之後。請讓我知道我能做些什麼來解決這個問題,也歡迎任何其他提示。我後來打算檢查以確保用戶輸入了至少4名機組人員,但不知道如何去做。
一般來說,你應該在你的問題後不爲紐帶,也可以爲您降低代碼來重現您的問題 – EdChum
錯誤是通過使用鍵盤造成所需的最小;它*不支持用戶輸入*;我不認爲你在問這個問題,所以我省略了。 –
我可以保證'crew'永遠不會等於0,你總是調用'find_shelter()'不管輸入什麼 –