2014-02-20 79 views
-4
def shut_down(s): 
    s = s.Lower() 
    if s == 'yes' : 
     return "Shutting down..." 
    elif s == 'no': 
     return "Shutdown aborted!" 
    else : 
     return "Sorry, I didn't understand you." 

電腦告訴我,你shut_down函數拋出了以下錯誤:「海峽」對象有沒有屬性「下」關於字符串蟒蛇問題

+4

Python是一種區分大小寫的語言。該方法被命名爲'lower()',而不是'Lower()'。 –

+0

使用'lower()'而不是'Lower()' – 2014-02-20 14:43:02

回答

1

.Lower()不蟒蛇用,因爲它是區分大小寫的語言使用.lower()

 def shut_down(s): 
     s = s.lower() 

     if s == 'yes' : 
       return "Shutting down..." 
     elif s == 'no': 
       return "Shutdown aborted!" 
     else : 
      return "Sorry, I didn't understand you."