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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -