Skip to main content

Membership operators in Python

 



x = "Saransh"

print('S'in x)

OUTPUT
TRUE

x = "Saransh"
print('v'in x)

OUTPUT
FALSE

# sentences case (h ,H)
x = "Saransh"
print('H'in x)

output
False


x = "xpple"

if "A" in x:
print("yes a is found")
else:
print("No,not found")

OutPut:
No,not found


 x = "Apple"

if "A" in x:
print("yes a is found")
else:
print("No,not found")

OutPut

yes a is found

Comments