List, Tuple and Iteration Data Types
The list of methods is discussed in this article.
1. The "in" operator : — This operator is used to check for an element in the list. Returns true if the item is in the list, otherwise returns false.
2. Not in operator : — This operator is used to check if an item is missing from the list or not. Returns true if the element is not in the list, otherwise returns false.
|
Output:
List is ha ving element with value 4 List is having element with value 4
3. len () : — This function returns the length of the list.
4. min () : — This function returns the minimum list item.
5. max () : — This function returns the maximum list item.
|
Output:
The length of list is: 5 The minimum element of list is: 1 The maximum element of list is: 5
6. Operator "+" : — This operator is used to combine two lists into one list.
7. Operator "*" : — This operator is used to multiply a list n times and return one list.
|
Output:
list after concatenation is: 1 2 3 4 5 6 list after combining is: 1 2 3 1 2 3 1 2 3
8. index (ele, beg, end) : — This function returns the index of the first occurrence of an element from the beginning to the end.
9. count () : — this function counts the number of occurrences of elements in the list.
|
Output:
The first occurrence of 3 after 3rd position is: 5 The number of occurrences of 3 is: 2
Related Articles:
List of methods in Python
List of Methods in Python | Set 2 (del, remove (), sort (), insert (), pop (), extend () ...)
This article is contributing to Manjeet Singh If you love Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or post the article [email protected] See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.