When writing code, you need to check the string for the presence of characters, as well as Latin letters (az and AZ). ps re library installed.

Example:

a = 'apple1' False b = 'apple*' True 
  • I wonder how you installed the standard library re ...;) - MaxU
  • I wrote it for sure, because on stack'e I was completely deprived of questions for 6 days to ask))) - jetsame
  • "check the string for the presence of characters" ... Ahem - Daniel Sereda

1 answer 1

 import re import string In [17]: pat = '^[a-zA-Z{}]+$'.format(re.escape(string.punctuation)) In [18]: bool(re.match(pat, 'apple1')) Out[18]: False In [19]: bool(re.match(pat, 'apple*')) Out[19]: True