[python] How to check a string for specific characters?