- Prepare
- Python
- Strings
- String Validators
- Discussions
String Validators
String Validators
+ 0 comments if __name__ == '__main__': s = input() a, b, c, d, e = False, False, False, False, False for i in s: if a == False: a = i.isalnum() if b == False: b = i.isalpha() if c == False: c = i.isdigit() if d == False: d = i.islower() if e == False: e = i.isupper() print(a,b,c,d,e, sep = '\n')
+ 0 comments if __name__ == '__main__': s = input() hasNumber= any(char.isdigit() for char in s) hasAlphaNumeric=any(char.isalnum() for char in s) hasAnyAlpha=any(char.isalpha() for char in s) haslowerCase=any(char.islower() for char in s) hasUpperCase=any(char.isupper() for char in s) print("True" if hasAlphaNumeric else "False") print("True" if hasAnyAlpha else "False") print("True" if hasNumber else "False") print("True" if haslowerCase else "False") print("True" if hasUpperCase else "False")
+ 0 comments s = input() if any(ele.isalnum() for ele in s): print(True) else: print(False)
if any(ele.isalpha() for ele in s): print(True) else: print(False) if any(ele.isdigit() for ele in s): print(True) else: print(False) if any(ele.islower() for ele in s): print(True) else: print(False) if any(ele.isupper() for ele in s): print(True) else: print(False)
+ 0 comments def apply_func(x,func): return eval(f"x.{func}()")
def apply_string(x,func): for i in range(len(x)): if apply_func(x[i],func) == True: return True return False
if name == 'main': s = input() print(apply_string(s,'isalnum')) print(apply_string(s,'isalpha')) print(apply_string(s,'isdigit')) print(apply_string(s,'islower')) print(apply_string(s,'isupper'))
+ 0 comments s=input() alpha="False" alphe="False" digit="False" lower="False" upper="False" for i in s: if i.isalnum()==True: alpha="True" if i.isalpha()==True: alphe="True" if i.isdigit()==True: digit="True" if i.islower()==True: lower="True" if i.isupper()==True: upper="True" print(alpha) print(alphe) print(digit) print(lower) print(upper)
Sort 1437 Discussions, By:
Please Login in order to post a comment