gpt4 book ai didi

python - 检查密码库的长度

转载 作者:太空宇宙 更新时间:2023-11-03 21:07:53 24 4
gpt4 key购买 nike

更新的错误代码,现在可以成功检查输入以及最大和最小值更新的错误代码,现在可以成功检查输入以及最大和最小值更新的错误代码,现在可以成功检查检查输入以及最大值和最小值

print("------------------------------------------------------------------------")
print('''Welcome to password Locker, a place where you can
store all your passwords to easily enter your precious accounts without
hassle.''')
print("------------------------------------------------------------------------")



print('''First lets make an account,''')

while True:
first_name = input('''What is your first name?''')
if first_name.isdigit(): #isdi
print("No numbers")
else:
print("Eligible")
break

while True:
sur_name = input('''What is your surname?''')
if sur_name.isdigit(): #isdi
print("No numbers")
else:
print("Eligible")
break

print('''----------------------------------''')
print('''Welcome, {} {}
what would you like your username to be, it should be something
memorable and no longer than ten characters long'''.format(first_name, sur_name))
while True:
username = input("")
if 0 < len(username) < 10:
print('''Nice, username''')
break
elif not username:
pass

else:
print('''Your username should be a maximum of 10 charecters''')
while True:
locker_password = input('''Now it's time to setup a password for your locker: ''')
if len(locker_password) > 4 and len(locker_password) < 11:

print('''{}, is locked in thanks for joining Password Locker'''.format(locker_password))
else:
print("It should be between 4 and 10 charecters long!")```


[1]: /image/4JnoH.png

最佳答案

添加带有条件的 elif 并稍微修改 if 条件:

username = input('''Welcome, {} {} 
what would you like your username to be, it should be something
memorable and no longer than ten characters long
'''.format(first_name, sur_name))
while True:
username = input()
if 0 < len(username) < 10:
print('''Nice, username''')
break
elif not username:
pass

else:
print('''Your username should be a maximum of 10 charecters''')

示例输出:

Welcome, Bob Smith 
what would you like your username to be, it should be something
memorable and no longer than ten characters long

Welcome, Bob Smith
what would you like your username to be, it should be something
memorable and no longer than ten characters long
12133254827258426763589
Your username should be a maximum of 10 charecters
Welcome, Bob Smith
what would you like your username to be, it should be something
memorable and no longer than ten characters long
abc
Nice, username

关于python - 检查密码库的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55276501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com