登录名和密码变量

问题描述

下午好!我被告知在 repl.it 上使用 python 执行登录和密码变量。

程序应该检查这些值:

  1. 密码必须由数字和字母组成,长度至少为 8 个字符
  2. 登录名必须为 5 个字符或更多

否则,程序必须打印错误

要求在初学者水平上做所有事情,而不使用库或其他

谢谢!

解决方法

我只是给你举个例子。 将 x 作为登录变量,y 作为密码登录,例如。 -

x = input('Enter Username ')

if len(x) >= 5:
    y = input('Enter Password ')
    if y.isalpha() == True or y.isdigit() == True:
        print('Password must contain both Letters and Numbers')

    else:
        if len(y) >= 8:

            print('Password Accepted')

        else:
            print('Password must be 8 or more letters')

else:
    print('Username must be 5 or more letters')