首页 > 解决方案 > 安全密码游戏的 If 语句

问题描述

对于我的家庭作业,我需要创建一个安全密码游戏,用户可以在其中输入自己的密码,程序将运行以查看密码是否符合安全密码的要求。如果没有,它会打印出原因,并让您输入不同的密码。

我只需要关于下面“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: $ % @ ! ? *")

标签: python-3.x

解决方案


推荐阅读