我试图为相同的输入获取不同的消息,但是它不起作用,例如,当我运行该程序并首次输入am <0时,我希望有message(0),但对于下次输入am <0
就像科尔托纳!当您问她相同的问题时,她不会回答相同的问题。
def smart(m):
if m<0 :
messages(0)
if m<0 : #for the second entered m!
messages(1)
else:
messages(4)
def messages(n):
if n==0:
print "Please enter a positive integer!"
if n==1:
print "Dude! i told you a positive integer!"
elif n==2:
print "Are you deaf?! A POSITIVE INTEGER!!!"
elif n==3:
print "Do you want to f*** with my mind m***********?!"
elif n==4:
print "finally"
我认为这就是您要寻找的。进行此类操作的最佳方法是使用while循环来不断提示用户。尽管大多数人不需要多个不同的消息。
message = ""
n = 0
while not message.isdigit():
if n == 0:
message = raw_input("Please enter a positive integer! ")
elif n == 1:
message = raw_input("Dude! i told you a positive integer! ")
elif n == 2:
message = raw_input("Are you deaf?! A POSITIVE INTEGER!!! ")
elif n >= 3:
message = raw_input("Do you want to f*** with my mind m***********?! ")
n += 1
if n > 1:
print "finally"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句