Home | | Computer Science 12th Std | Membership Operators

Python - Membership Operators | 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation

Chapter: 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation

Membership Operators

The ‘in’ and ‘not in’ operators can be used with strings to determine whether a string is present in another string.

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

 


Tags : Python , 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation : Membership Operators | Python


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.