为什么我运行这个时什么都没有发生?

选择 | 换行 | 行号
  1. from sys import exit
  2. from random import randint
  3.  
  4.  
  5. def main_hall():
  6.     print "You are on the war ship. You need to get into the elevator to get to the bridge; where the General is."
  7.     print "The whole destroyer is on alert and nearly every door is locked. There is a keypad on the elevator."
  8.     print "There is a warning saying you only have 10 attemps, then the system deactivates and you cannot complete your mission. Be careful!"
  9.  
  10.     combination = "%d%d%d"  % (randint(1,9), randint(1,9), randint(1,9))
  11.  
  12.     guess = raw_input ("[Keypad:] ")
  13.  
  14.     guesses = 0
  15.  
  16.     while guess != combination and guesses < 10:
  17.         print "*BZZT!* ERROR 2355: Incorrect combination!"
  18.         guesses += 1
  19.         guess = raw_input
  20.  
  21.     if guess == combination:
  22.         print "You open the elevator and start going up, fast. When you get to the top, you are at a T-junction. Do you go left or right?"
  23.         return 'junction'
  24.  
  25.     else:
  26.         print "You have had more than 10 attempts! \n A small self destruct system in the lock blows you up!\n"
  27.         return 'death'
  28.  
  29.  
  30.  
  31.  
  32.  
  33. def death():
  34.     lols = ["NO! You have failed this mission!", "Game over kid!", "You are really bad.", "Mission over, you may aswell go home."]
  35.     print lols(0, len(lols)-1)
  36.     exit (1)

这是我的游戏版本。我这样做是为了一个学习python的练习,一个书本教程。为什么什么都没有发生?没有错误消息,只是什么都没有发生……谢谢!

# 回答1

您从不调用main_hall函数。
# 回答2

我该怎么做?我还不太擅长python
# 回答3

通过键入函数的名称。

选择 | 换行 | 行号
  1. def hello():
  2.     print "Hello World!"
  3.     return
  4.  
  5. hello()

标签: python

添加新评论