如何检查字符串是否不等于某个值?

时间:2014-05-21 22:57:25

标签: python

所以这是我到目前为止对我的调查问卷的编码。在第6行,如果用户输入一组不是1234的随机字符,如何使其打印无效?

 print ("Welcome, Please enter your Canadian Armed Forces Identification Number")
 answer = raw_input()
 if answer == ("1234"):
     print " Please identify yourself "
 elif answer == "":
     print " Invalid ID "
     print " 3 More attempts before termination of program "
 name= raw_input()

 if answer == ("Silva"):
     print " Welcome, Silva "

1 个答案:

答案 0 :(得分:0)

if answer == ("1234"):
    print " Please identify yourself "
else:
    print " Invalid ID "
    print " 3 More attempts before termination of program " name= raw_input()