Membership Operators
The ‘in’
and ‘not in’ operators can be used
with strings to determine whether a string is present in another string.
Therefore, these operators are called as Membership Operators.
Example
str1=input ("Enter a string:
")
str2="chennai"
if str2 in str1:
print ("Found")
else:
print ("Not Found")
Output : 1
Enter a string: Chennai G HSS,
Saidapet
Found
Output : 2
Enter a string: Govt G HSS, Ashok
Nagar
Not Found
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.