python-3.x - 安全密码游戏的 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 - 数据框线图未绘制具有列值的线
- javascript - 使用 JavaScript 时如何在对象数据中使用可选链接?
- javascript - Jest 测试函数忽略前两个参数
- instagram - Sanity.io API 从 URL 上传图片
- java - 当我尝试将 html 转换为 pdf 时,Itext7 抛出错误
- mysql - SQL:查询在一个字段中查找具有共同值的多个项目
- algorithm - 如何设计一个系统以在时间窗口中查找前 K 个热门帖子
- angular - 占位符上的 setValue 问题
- c# - 如何在 C# 中使用 JSON-Body 和代理进行发布请求?
- typescript - 如何通过嵌套对象推断类型