2016-12-24 76 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() 

這是怎麼回事?它只是不打印時,我什麼都 它只是跳過和犯規打印任何東西我似乎無法運行這個簡單的python腳本

+2

您的函數調用'reply()'在return語句之後。那就是問題所在。 –

+0

您需要對函數,參數,參數,範圍,執行順序等進行更多的研究。 – TigerhawkT3

回答

1

你的解答()函數類型將不會被調用,因爲你通過返回的答案

退出提示()函數這是應該如何完成的:

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() 
相關問題