[英]Is there any way in python to repeat a while or for loop by asking the user to do so at the end of the loop?
[英]repeat a function while loop not end in python
嘿伙计们,我正在玩我的小项目,我遇到了关于如何重复一个函数的问题再次调用这个
代码如下:
#this function is to check user and pass that was entered by the user using the inputs function
def chk(u = str(a[0]), p = int(a[1])):
while u not in sales_man.keys():
call this function again
如果你想实现一个简单的登录,你可以使用经典的无限循环,如:
def check_user(user):
return user in sales_man.keys()
while True:
# [...] get username in input
if check_user(username):
# [...] ok, check password
else:
# [...] wrong user
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.