Ad Code

✨🎆 Codex 1.0 PLACEMENT READY PROGRAM! 🎆✨

Get 75% Discount Early bird offer CLICK to JOIN CodeX 1.0 click

is,is not operator and in ,not in operator in LIST in Python

Python List Operators

Using is, is not, in, and not in Operators in Python List


1) is Operator

The is operator compares the memory address of list, tuple, set, or dictionary objects. If both variables refer to the same object/address, it returns True, otherwise False.

x = [1,2,3]
y = [1,2,3]

if x is y:
    print("equall")
else:
    print("not equall")
Output:
not equal

2) is not Operator

The is not operator is the opposite of is. It returns True when two variables have different memory addresses.


3) in Operator

The in operator checks whether a value exists in a List, Tuple, Dictionary, or Set.

Example:
x = [1,2,3,4,5]

if 21 in x:
    print("exist")
else:
    print("not exist")

Post a Comment

2 Comments

  1. Q:- Implementation of "is" in Pythone Program ?
    Solution:-
    a= ["Computer", "Laptop", "Android", "iPhone","Windows"]

    if "Linux" in a:

    print("It is Presented in List.")

    else:

    print("It is Not Presented in List.")

    ReplyDelete
  2. Program of IS operator--->

    y=["Python","Java","C","C++","VB"]
    if ".Net" in y:
    print("it is there")
    else:
    print("it is not there")

    ReplyDelete

POST Answer of Questions and ASK to Doubt