1
나는 이것을 실행할 때마다 s = 'yes'이므로 첫 번째를 반환해야 할 때 세 번째 옵션을 얻습니다. 여기서 뭐가 잘못 됐어?내 조건이 "none"을 반환하는 이유는 무엇입니까?
def shut_down(s):
if s is 'yes':
return 'Shutting down...'
elif s is 'no':
return 'Shutdown aborted!'
else:
return "Sorry, I didn't understand you"
ans = 'Yes'
s = ans.lower()
shut_down(s)
이 http://stackoverflow.com/questions/2988017/string-comparison-in-python-is-vs의 반복이다 –