如何修复语法错误';继续';在python的循环中不正确
我想创建一个简单的数据库,它将存储和返回数据 问题是如何修复语法错误';继续';在python的循环中不正确,python,database,loops,deadlock,Python,Database,Loops,Deadlock,我想创建一个简单的数据库,它将存储和返回数据 问题是continue似乎不起作用。 执行函数检查器中的else语句后,它将继续打印“重试”,并且似乎处于死锁状态 def checker(): #Checks if the password is strong enough while True: if (p[0].isupper() and not p.isalpha() and len(p) > 7): print('Password Created!') break
continue
似乎不起作用。
执行函数检查器
中的else语句后,它将继续打印“重试”,并且似乎处于死锁状态
def checker():
#Checks if the password is strong enough
while True:
if (p[0].isupper() and not p.isalpha() and len(p) > 7):
print('Password Created!')
break
#If password is not strong enough try again
else:
print('Try Again')
continue
#Starts main program
while True:
database = {'dom':'yeet'}
welcome = input('Welcome! To login press L, if you are new press R: ')
#Login will log basically check if your info is in dictionary
if welcome == 'L':
for user in database.keys():
u = input('Username: ')
if u in user:
for passw in database.values():
p = input('Password: ')
if p in passw:
print('Welcome ' + str(u))
break
#Will create new user in dictionary
elif welcome == 'R':
u = input('Choose your username: ')
p = input('Choose your password: ')
#Runs checker function
checker()
database[u] = p
print('Welcome ' + str(u))
break
else:
continue
重写检查器(),如下所示:
您对else块使用了不正确的缩进,它超出了循环
def checker():
#Checks if the password is strong enough
while True:
if (p[0].isupper() and not p.isalpha() and len(p) > 7):
print('Password Created!')
break
else:
print('Try Again')
continue
重写检查器(),如下所示:
您对else块使用了不正确的缩进,它超出了循环
def checker():
#Checks if the password is strong enough
while True:
if (p[0].isupper() and not p.isalpha() and len(p) > 7):
print('Password Created!')
break
else:
print('Try Again')
continue
Python编码的美妙之处在于,您必须正确地缩进代码,记住这一点,每个人都会自动编写漂亮的代码,而且您永远不会看到格式不好的Python代码。
缩进你的其他部分,你就可以开始了。Python编码的美妙之处在于你必须正确地缩进代码,记住这一点,每个人都会自动编写漂亮的代码,你永远不会看到格式不好的Python代码。
缩进你的其他部分,你就可以开始了。你需要了解什么时候可以使用continue,什么样的循环可以接受continue,这是初学者应该在docsI中寻找的东西。修复了,从func开始,这是一个不好的意图,但现在我有了其他错误,你需要了解什么时候可以使用continue,什么样的循环可以接受它,这是初学者应该在docsI中寻找的东西。修复了,从func开始,这是一个不好的意图,但现在我有了其他错误,其他垃圾邮件再试一次