我只是玩弄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