Lists are one of the most powerful tools in Python. They are just like the arrays declared in other languages. But the most powerful thing is that list need not be always homogeneous. A single list can contain strings, integers, as well as objects. Lists can also be used for implementing stacks and queues. Lists are mutable, i.e., they can be altered once declared.
# Declaring and printing list L = [1, "a" , "string" , 1+2] print(L) # Adding more items L.append(6) print(L) # Removing an item L.pop() print(L) # Printing a particular item print(L[1])
The output is :
[1, 'a', 'string', 3] [1, 'a', 'string', 3, 6] [1, 'a', 'string', 3] a
Recent Articles on Python List
Built-in Functions, Programs of List
- Append(): Add an element to the end of the list
- Extend(): Add all elements of a list to the another list
- Insert(): Insert an item at the defined index
- Remove(): Removes an item from the list
- Pop(): Removes and returns an element at the given index
- Clear(): Removes all items from the list
- Index(): Returns the index of the first matched item
- Count(): Returns the count of number of items passed as an argument
- Sort(): Sort items in a list in ascending order
- Reverse(): Reverse the order of items in the list
- Copy(): Returns a shallow copy of the list
- Comprehension and slicing
- List Methods in Python – Set 1 Set 2
- Python map function to find row with maximum number of 1’s
- Numbers in a list within a given range
- Print list after removing element at given index
- Extending a list in Python
- Check if all the values in a list that are greater than a given value
- Comprehension to find pair with given sum from two arrays
- Get unique values from a list
- Lambda expression and filter function
- Prefix sum array in Python using accumulate function
- Check whether two lists are circularly identical
- Check whether a list is empty or not
- Check if two lists have at-least one element common
- List Slicing
- Difference between two lists
- Maximum and minimum element’s position in a list
- Print first m multiples of n without using any loop in Python
- Print first m multiples of n without using any loop in Python
- Program to check if two given matrices are identical
- Sort the values of first list using second list
- Print all the common elements of two lists
- Print all sublists of a list
- Iterate over multiple lists simultaneously
- Segregate 0’s and 1’s in an array list
- Count occurrences of an element in a list
- Reversing a List
- Count set bits using Python List comprehension
- Creating a 3D List
- Creating a sorted merged list of two unsorted lists in Python
- Remove Duplicates from a List
- Largest, Smallest, Second Largest, Second Smallest in a List
- Find average of a list in python
- Sort a List according to the Length of the Elements
- Intersection of two lists
- Multiply all numbers in the list
- Generate random numbers within a given range and store in a list
- Union of two or more Lists
- Remove and print every third from list until it becomes empty
- Python Slicing
- Print anagrams together in Python using List and Dictionary
- List comprehension and ord() in Python
- Move all zeroes to end of array using List Comprehension in Python
- Sort a list according to the second element in sublist
- Convert an array to an ordinary list with the same items
- Python program to find Cumulative sum of a list
- Find missing and additional values in two lists
- Split the Even and Odd elements into two different lists
- Cloning or Copying a list
More Useful Links
- Recent Articles on Python List
- Output of Python Programs in List : Set 6, Set 11, Set 12, Set 13
- Recent Articles on Python
- Coding Practice Platform
- Multiple Choice Questions
- All articles in Python Category
- Python Tutorials
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.
Recommended Posts:
- Output of C++ Programs | Set 49
- Assigning multiple characters in an int in C language
- Output of C programs | Set 65 (If-Else)
- Output of C programs | Set 64 (Pointers)
- Output of Python Programs | Set 24 (Sets)
- Output of Java Programs | Set 53 (String Comparison)
- Output of Java Programs | Set 52 (Strings Class)
- Output of Python Programs | Set 23 (String in loops)
- Output of Python Programs | Set 22 (Loops)
- Output of Python Programs | Set 21 (Bool)
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.


