python 3.x - check if a string only contains certain letters -
in python how create function checks see if user enter string contains letter , b? string can long user wants should contains combination of letters , b. thanks.
alternatively using regular expressions, use generator expression checking whether all
characters in
string "ab"
.
>>> all(c in "ab" c in "foobar") false >>> all(c in "ab" c in "aaabaababbba") true
Comments
Post a Comment