Python | Check If A Given Object Is A List Or Not Last Updated : 16 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Given an object, the task is to check whether the object is a list or not. Python provides few simple methods to do this and in this article, we'll walk through the different ways to check if an object is a list:Using isinstance()isinstance() function checks if an object is an instance of a specific class or data type. Python if isinstance([1, 2, 3], list): print("Object is a list") else: print("Object is not a list") if isinstance("12345", list): print("Object is a list") else: print("Object is not a list") OutputObject is a list Object is not a list Explanation:isinstance(obj, list) returns True if obj is a and False if it's not.Using type()Another method to check if an object is a list is by using the type() function. This function returns the exact type of an object. Python l1 = [1, 2, 3] l2 = (10, 20, 30) # A tuple if type(l1) is list: print("Object is a list") else: print("Object is not a list") if type(l2) is list: print("Object is a list") else: print("Object is not a list") OutputObject is a list Object is not a list Explanation:type(obj) returns the exact type (e.g., list, tuple, dict).Unlike isinstance(), it does not consider inheritance, useful when strict type matching is needed.Using __class__ AttributeTo check if an object is a list , we can use the __class__ attribute and compare it to the list type: Python l1 = [1, 2, 3, 4, 5] l2 = (12, 22, 33) if l1.__class__ == list: print("input is a list") else: print("input is not a list") if l2.__class__ == list: print("input is a list") else: print("input is not a list") Outputinput is a list input is not a list Explanation:__class__ returns the class of an object.While it works, it’s less readable and not as commonly used as isinstance(). Comment More infoAdvertise with us Next Article Python | Check If A Given Object Is A List Or Not G garg_ak0109 Follow Improve Article Tags : Python Python Programs python-list Python list-programs Practice Tags : pythonpython-list Similar Reads Python | Check if a list exists in given list of lists Given a list of lists, the task is to check if a list exists in given list of lists. Input : lst = [[1, 1, 1, 2], [2, 3, 4], [1, 2, 3], [4, 5, 6]] list_search = [4, 5, 6] Output: True Input : lst = [[5, 6, 7], [12, 54, 9], [1, 2, 3]] list_search = [4, 12, 54] Output: False Letâs discuss certain ways 4 min read Check If Value Exists in Python List of Objects When working with Python, we might need to check whether a specific value exists in a list of objects. This problem often arises when dealing with data stored as objects and we want to verify the presence of a specific property value. Using any() Function with List Comprehensionany() function is an 4 min read Python program to check if a given string is Keyword or not This article will explore how to check if a given string is a reserved keyword in Python. Using the keyword We can easily determine whether a string conflicts with Python's built-in syntax rules.Using iskeyword()The keyword module in Python provides a function iskeyword() to check if a string is a k 2 min read Check if a Nested List is a Subset of Another Nested List - Python The task is to check if all sublists in one nested list are present in another nested list. This is done by verifying whether each sublist in the second list exists in the first list.For example, given list1 = [[2, 3, 1], [4, 5], [6, 8]] and list2 = [[4, 5], [6, 8]], we check if both [4, 5] and [6, 4 min read Python - Check if any list element is present in Tuple Given a tuple, check if any list element is present in it. Input : test_tup = (4, 5, 10, 9, 3), check_list = [6, 7, 10, 11] Output : True Explanation : 10 occurs in both tuple and list. Input : test_tup = (4, 5, 12, 9, 3), check_list = [6, 7, 10, 11] Output : False Explanation : No common elements. 6 min read Like