2👍
✅
Your current regex checks that your value contains a single character from a-z. So it allows a
, but it also allows a1
.
Try changing the regex to:
regex=r"^[a-z]+$"
By including ^
and $
to mark the beginning and end of string, you make sure that your string contains only characters from a-z. The +
allows multiple characters.
Source:stackexchange.com