w1coding.comAll tutorials

Python Lists

Python lessons
  1. Environment Setup
  2. Introduction
  3. Control
  4. Control
  5. Loops
  6. Functions
  7. Lists
  8. Dictionary
  9. Classes
  10. Exception
  11. File
  12. Libray
  13. Date
  14. Regula
  15. JSON
  16. Web
  17. Zweb
  18. Apis
  19. Unity
  20. Llampda
  21. Iterators
  22. Generators
  23. Files
  24. Context
  25. Ilogging
  26. Multithreading
  27. Networking
  28. SQLite

Python Lists

Lists in Python are ordered collections of items. You can store multiple values in a single list.

Creating a List

You can create a list by enclosing items in square brackets:

      
        fruits = ["apple", "banana", "cherry"]
        print(fruits)
      
    

This creates a list of fruits and prints it.

Accessing List Elements

You can access elements in a list by their index:

      
        first_fruit = fruits[0]
        print(first_fruit)
      
    

This prints the first element, "apple". Remember that Python uses 0-based indexing.

Activity

Try It Yourself!

Create a list of your favorite movies and print the second one in the list.