【发布时间】:2019-03-01 09:55:30
【问题描述】:
我只是想为自己编写一个代码,但在我的代码中调用特定函数时遇到问题,这很奇怪,因为我已经有另外 2 个函数,就像这个函数一样,他们正确地完成了他们的工作,检查一下
import random
name = ("aghayan","jafari","panahi","kashkool")
word = random.choice(names)
dash_guess = "-" * len(word)
guesses_left = 5
class hangman():
def Entrance():
print(" one of your python classmates was an undercover cop and set a ")
print(" trap for our Boss Mohammad Esmaili!'THE CARTEL KING' so they arrest him .")
print(" we just need that snitch name and your the only person of that")
print(" class that we have access to , so your going to tell us the snitch")
print(" name or i will hang you my self and you got only 5 chances to ")
print(" tell me his or hers name or you'll die")
print()
def repeat():
your_choice =input(" so will you help me or you want to die ? 'yes' or 'no' : ")
if your_choice == "yes":
print("Good it seems you have someone waiting for you and you want to ")
print("see him/her again , you better be telling the truth or i,ll go ")
print("and pay a visit to your love")
core_game(guess)
elif your_choice == "no":
print("ok good choice , it will be my pleasure to kill you ")
print("________ ")
print("| | ")
print("| 0 ")
print("| /|\ ")
print("| / \ ")
print("| ")
print("Adios my friend , i hope you rest in peace in HELL")
exit()
else :
print(" it seems the noose tightens around your neck and its getting")
print(" hard to talk but i just need 'yes' or 'no' for answer")
repeat()
repeat()
Entrance()
def core_game(guess):
while guesses_left > 0 and not dash_guess == word:
guess = input("so tell me that snitch name letter by letter : ")
if guess != 1:
print("NOPE , i need you to spell the name of that rat")
core_game(guess)
game = hangman()
它不完整,但问题是当我输入“是”时,它应该将程序带到 def core_game() 但它给我错误“未定义 core_game”。
【问题讨论】:
-
您的代码中的缩进是否正确?因为这里看起来不正确。
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: python-3.x function class object