我想比較一個輸入字符串,但是當我輸入barack作爲輸入時,編譯器直接轉到其他條件,忽略if條件並給我輸出「Wrong答案「比較字符串與輸入字符串:: python
def main():
First_name = raw_input(" enter the first name of President Obama : ") #input
if First_name == ['b', 'a', 'r','a', 'c', 'k'] :
print "Correct answer"
else :
print "Wrong answer"
Exit_key = input('Press any key to end')
你爲什麼認爲輸入是一個列表?! – jonrsharpe 2014-11-04 22:38:16
Python字符串不是char數組。 – 2014-11-04 22:41:11