对于我的家庭作业,我需要创建一个“安全密码”游戏,用户可以在其中输入自己的密码,然后程序将运行以查看该密码是否符合要求。 如果不是,那么它将打印出不存在的原因,并让您输入其他密码。
我仅需要有关下面的“ if countsymbols”的If语句的帮助。
密码必须包含列出的6个特殊符号中的至少1个。
我是python的新手,所以任何帮助都会很棒!
到目前为止,这就是我所拥有的。
print ("Welcome to the PASSWORD game of \"Jojo\"!")
Password = input( "Please enter a password (Enter q to quit): ")
#When the user inputs "q" then the Game will end.
q = quit
if Password == q:
quit
print("Thank you for playing this PASSWORD game. Hope to see you again! ")
# Start of code.
while (Password != q):
print("The password you just entered is", Password)
countsymbols = 6 # of 6 special symbols $ % @ ! ? *
countsymbols += pw.count('$')+pw.count('%')+pw.count('@') +pw.count('!') +pw.count('?')
if countsymbols #I NEED HELP HERE
print( "Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *")