Is there a way to locate capital letters and digits in a string?
Here is the code I have so far:
# Imports
import random
# Variables
my_score = 0
loop = True
# start
while loop == True:
username = input("Enter your username")
has_digit = False
has_upper = False
I tried searching Google but I couldn’t find anything that seems to work, any ideas?
>Solution :
import re
has_upper = True if re.search('[A-Z]', username) else False
has_digit = True if re.search('\d', username) else False