我只是玩弄If Else語句,我想知道如何讓它循環再次問這個問題,如果第一個If Else是真的。Python如果Else語句語法錯誤
此外,你會如何在最後添加一個通用的Else以使其對於放入的任何其他名稱有所說明?
我在Python 2.7
在Raspberry Pi.
#!/usr/bin/python
name=""
while name !="quit":
name = raw_input("What is your name? ")
print "Hello", name
import time
time.sleep(2)
if name == "Jack":
print "Jack, I have decided that you are awesome."
time.sleep(2)
print "And I am a computer so I cannot be wrong"
else:
print "Oh, you are not Jack?"
time.sleep(2)
print "Haha, Jack is better than you"
if name == "Ronan":
print "Ronan, I know everything about you."
time.sleep(2)
print "For example, I know you hate cats."
else:
print "Oh, you are not Ronan?"
time.sleep(2)
print "Perhaps you can convince him that he loves cats"
'打印「哈哈,傑克優於you'需要一個最終報價 –
是的,對不起,我已經固定的任何其他錯誤,但由於:) – Ferex