Python用户名功能

问题描述

 function input(userName)

valid = True

if len(userName) > 10 or len(userName) < 5

    valid = False

endif

return valid uName = input("Enter your username: ")

if not validUsername(uName)

print("That isn't a valid username")

endif

我的功能无法正常工作,有人可以帮助我修复它吗?我很困惑,我正在努力使其正常工作。

解决方法

我很难理解您的问题,但是我编写了一个简单的程序,我想您正在问这个问题?

def function_name():
usrinput = input("Type in your username: ")
valid = True
if len(usrinput) > 10 or len(usrinput) < 5:
    print("Username is valid")
else:
    print("This is not a valid username")

function_name()