2016-12-24 4 views
-3
however = ["In converse","On the other hand"] 
furthermore = ["To add insult to injury","To add fuel to fire",] 
conclusion = ["To ram the point home","In a nutshell"] 
def prompt(): 
    answer = str(input("Type either 'however','furthermore' or 'conclusion': ")) 
    return answer 
    reply() 

def reply(): 
    if answer == "however": 
     print(however) 
    elif answer == "furthermore": 
     print(furthermore) 
    elif answer == "conclusion": 
     print(conclusion) 
    else: 
     prompt() 
    prompt() 

prompt() 

何が起こっているのですか?それだけでdoesntの印刷私はあなたが答え私はこの単純なpythonスクリプトを実行することができません

を返すことによってプロンプト()関数を終了するので、呼び出されません全て

+2

関数呼び出しの 'reply()'はreturn文の後にあります。それは問題です。 –

+0

関数、パラメータ、引数、スコープ、実行順序などの詳細な調査を行う必要があります。 – TigerhawkT3

答えて

1

お返事()関数で何 それだけスキップしてdoesntの印刷何を入力するときこれを行う方法は次のとおりです。

however = ["In converse","On the other hand"] 
furthermore = ["To add insult to injury","To add fuel to fire",] 
conclusion = ["To ram the point home","In a nutshell"] 
def prompt(): 
    answer = str(input("Type either 'however','furthermore' or 'conclusion': ")) 
    reply(answer) 
    return answer 


def reply(answer): 
    if answer == "however": 
     print(however) 
    elif answer == "furthermore": 
     print(furthermore) 
    elif answer == "conclusion": 
     print(conclusion) 
    else: 
     prompt() 
    prompt() 

prompt() 
関連する問題