Python List Programs, Exercises, and Examples

In Python programming language, a list is a versatile and most used data type, it is just like a dynamically sized array. A list is used to store multiple items (of the same type as well as mixed type) in a single variable. Lists are created using the square brackets []. List items are indexed, ordered, changeable, and may contain duplicate values.

This section contains solved Python programs on Lists (like, creating lists, retrieving data from the lists, change the existing values of list items, removing the list items, etc.), practice these list programs to enhance the Python programming skills working on multiple values stored in a single variable. These programs contain the solved code, explanation, and output.

Basic List Programs

  1. Python | Program to declare and print a list
  2. Python program to print list elements in different ways
  3. Python | Program for Adding, removing elements in the list
  4. Python | Program to print a list using 'FOR and IN' loop
  5. Python | Program to add an element at specified index in a list
  6. Python | Program to remove first occurrence of a given element in the list
  7. Python | Remove all occurrences a given element from the list
  8. Python | Program to remove all elements in a range from the List
  9. Python | Program to sort the elements of given list in Ascending and Descending Order
  10. Python | Program to find the differences of two lists
  11. Python | Program to Print the index of first matched element of a list
  12. Python | Program to find the position of minimum and maximum elements of a list
  13. Python | Program to input, append and print the list elements
  14. Python | Program to remove duplicate elements from the list
  15. Python | Program to Create two lists with EVEN numbers and ODD numbers from a list
  16. Python | Program to print all numbers which are divisible by M and N in the List
  17. Python | Create a list from the specified start to end index of another list
  18. Python | Create three lists of numbers, their squares and cubes
  19. Python | Create two lists with first half and second half elements of a list
  20. Iterate / traverse a list in reverse order in Python

Intermediate List Programs

  1. Python | print list after removing EVEN numbers
  2. Python | print list after removing ODD numbers
  3. Python | Input comma separated elements, convert into list and print
  4. Python | Convert a string to integers list
  5. Using List as Stack in Python
  6. Extend a list in Python (6 different ways with examples)
  7. Python program to find N largest and smallest elements from the list
  8. Python program for various list operations
  9. Find the index of an item in a list in Python
  10. Extract Even and odd number from a given list in Python
  11. Remove falsy values from a list in Python
  12. Remove multiple elements from a list in Python
  13. Check all elements of a list are the same or not in Python
  14. Check all elements are unique or not in Python
  15. Python program to print positive or negative numbers in a list
  16. Python program to extract keywords from the list
  17. Python program to remove empty list from a list of lists
  18. Python program to multiply all numbers of a list
  19. How to find the length of a list in Python (3 effective ways)?
  20. Python program to check if an element is present in list

Advanced List Programs

  1. Python program to swap any two elements in the list
  2. Python program to interchange first and last element in a list
  3. Python program to find the cumulative sum of elements of a list
  4. How to clone or copy a list in Python? Cloning or copying a list
  5. Python program to find the sum of number digits in list
  6. Python: Find the index of an item in a list
  7. Flattening a shallow list in Python
  8. How do I get last element of a list?
  9. Python: Check list is empty or not
  10. Accessing a list and its elements in Python
  11. Find the number of elements in a list in Python


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.