List basics have been covered in python in the set below
List methods are discussed in this articles.
1. “in” operator :- This operator is used to check if an element is present in the list or not. Returns true if element is present in list else returns false.
2. “not in” operator :- This operator is used to check if an element is not present in the list or not. Returns true if element is not present in list else returns false.
List is having element with value 4 List is having element with value 4
3. len() :- This function returns the length of list.
4. min() :- This function returns the minimum element of list.
5. max() :- This function returns the maximum element of list.
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 concatenate two lists into a single list.
7. “*” operator :- This operator is used to multiply the list “n” times and return the single list.
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 first occurrence of element after beg and before end.
9. count() :- This function counts the number of occurrences of elements in list.
The first occurrence of 3 after 3rd position is : 5 The number of occurrences of 3 is : 2
This article is contributed by Manjeet Singh .If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- List methods in Python
- List Methods in Python | Set 2 (del, remove(), sort(), insert(), pop(), extend()...)
- Python | Float type and its methods
- Accessing Attributes and Methods in Python
- Dunder or magic methods in Python
- Dictionary Methods in Python | Set 1 (cmp(), len(), items()...)
- Python Input Methods for Competitive Programming
- Python | Implementing 3D Vectors using dunder methods
- Dictionary Methods in Python | Set 2 (update(), has_key(), fromkeys()...)
- Analysis of Different Methods to find Prime Number in Python
- Python | Convert list of string to list of list
- Python | Convert list of tuples to list of list
- Python String Methods | Set 3 (strip, lstrip, rstrip, min, max, maketrans, translate, replace & expandtabs())
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python String Methods | Set 2 (len, count, center, ljust, rjust, isalpha, isalnum, isspace & join)