you shouldnt need to use regex for simple string checks.
Because str.lower() does not effect string'd digits, you can just check for upper
Because str.lower() does not effect string'd digits, you can just check for upper
listname = ['ONE', 'two', 'Thr33', 'four', 'FiVe368'] for name in listname: if any(char.isupper() for char in name): print(name.lower()) else: print("{} is good".format(name))
Output:one
two is good
thr33
four is good
five368
If you really had to check digit you could do that as welllistname = ['ONE', 'two', 'Thr33', 'four', 'FiVe368', '67', '245245'] for name in listname: if any(char.isdigit() or char.isupper() for char in name): print(name.lower()) else: print("{} is good".format(name))
Output:one
two is good
thr33
four is good
five368
67
245245
Recommended Tutorials: