Reputation: 185
i need to check existing of Character (*,&,$)
in Given String using python command such as given below?
Eg: stringexample='mystri$ng&*'
check stringexample contains any special symbols like *,&,$ then return true?
shall i try with string method __contains__()
Upvotes: 1
Views: 8869
Reputation: 212885
if any(c in stringexample for c in '*$&'):
...
or
if not set('*&$').isdisjoint(stringexample):
...
Upvotes: 0
Reputation: 46027
>>> stringexample = 'mystri$ng&'
>>> '*' in stringexample
False
>>> '$' in stringexample
True
>>> '&' in stringexample
True
>>>
Upvotes: 1