Username review function
Write a function that receives a username and if it was a character except the lowercase English letters, FALSE and otherwise TRUE
Write a function that receives a username and if it was a character except the lowercase English letters, FALSE and otherwise TRUE
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
def validate_username(username): for char in username: if not char.islower(): return False return True name=input("name: ") print(validate_username(name))
class name: def __init__(self,name1): self.name1=name1 def __str__(self): for i in self.name1: if not i.isupper(): return ('true') else: return ('flase') x=str(input('please enter your name:')) ob=name(x) print(ob)
def check_name(username):
if not username.isalpha() or not username.islower():
return False
return True
print(check_name('erphan'))
listt=[' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] username=input("enter username: ") def check_username(listt,username): listt_check=[] for i in username: if i in listt: listt_check.append("True") else: listt_check.append('false') if 'false' in listt_check: status='false' else: status="true" print(status) check_username(listt,username)
def Name_Karbari(n) :
H = "QWERTYUIOPLKJHGFDSAZXCVBNM"
for i in n :
if i in H :
return False
return True
def is_valid_username(username): # Checking whether all characters are in English lowercase username for char in username: if not ('a' <= char <= 'z'): return False return True # Example of how to use username_input = input("لطفاً نام کاربری را وارد کنید: ") if is_valid_username(username_input): print("نام کاربری معتبر است.") else: print("نام کاربری باید فقط شامل حروف کوچک انگلیسی باشد.")
def username(name): return True if name.islower() else False i=input("name:") print(username(i))
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.