鱼C论坛

 找回密码
 立即注册
查看: 1388|回复: 4

请各位大神帮我看一下为什么break:后提示invalid syntax,这是个密码验证系统

[复制链接]
发表于 2020-4-26 23:00:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
correct = 'fishc.com'
i = 3
print("Please input password:\n")
str = input()
if correct == str:
    print("Welcome to my system!")
else:
    i = i - 1
    while i != 0:
        str = input("Please input right password,you have i chance:\n")
        if correct == str:
            print("welcome to my system!")
            break:
        else:
            i = i - 1
            continue:
    print("You\'re no chance!")
    print("Goodbye!")
   
print("Please wait......")               
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-4-26 23:05:21 | 显示全部楼层
break后不要加冒号,continue也是一样
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-26 23:07:51 | 显示全部楼层
不用加冒号啊……
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-26 23:21:42 | 显示全部楼层
  1. continue , break 不用加冒号 ,invalid syntax 无效语法
  2. correct = 'fishc.com'
  3. i = 3
  4. print("Please input password:\n")
  5. str = input()
  6. if correct == str:
  7.     print("Welcome to my system!")
  8. else:
  9.     i = i - 1
  10.     while i != 0:
  11.         str = input("Please input right password,you have i chance:\n")
  12.         if correct == str:
  13.             print("welcome to my system!")
  14.             break
  15.         else:
  16.             i = i - 1
  17.             continue
  18.         print("You\'re no chance!")
  19.         print("Goodbye!")

  20. print("Please wait......")  
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-27 12:11:37 From FishC Mobile | 显示全部楼层
str是内置函数,换个变量作为string的输入
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-18 06:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表