{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 3. Lists\n", "\n", "In this section, we'll explore the power of lists in Python. We'll cover how to create, access, and modify lists to store and organize data efficiently.\n", "\n", "A **list** in Python is an ordered collection of items. It's a versatile data structure that can store elements of different types, including numbers, strings, and even other lists. Lists are mutable, meaning you can change their contents after they are created.\n", "\n", "We'll learn about the following topics:\n", "\n", " - [3.1. Creating Lists](#Creating_Lists)\n", " - [3.2. Built-in List Functions](#Builtin_List_Functions)\n", " - [3.3. List Indexing and Slicing](#List_Indexing_and_Slicing)\n", " - [3.4. List Properties](#List_Properties)\n", " - [3.5. List Operators](#List_Operators)\n", " - [3.6. Built-in List Methods](#Builtin_List_Methods)\n", " - [3.7. Nesting Lists](#Nesting_Lists)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n",
"
\n",
"
| Name | \n", "Type in Python | \n", "Description | \n", "Example | \n", "
|---|---|---|---|
| Lists | \n", "list | \n", "Comma-separated ordered sequence of objects in square brackets [ ]. | \n", "[10,'hello', 15.9] | \n", "
\n",
"
\n",
"
\n",
"
\n",
"
| Method | \n", "Description | \n", "
|---|---|
| append() | \n", "permanently add an item to the end of a list | \n", "
| insert(index, m) | \n", "inserts object m into the list at the specified index | \n", "
| pop(m(optional)) | \n", "By default pop takes off the last index, but you can also specify which index to pop off | \n", "
| remove(m) | \n", "removes object m from the list | \n", "
| reverse() | \n", "reverse order permanently | \n", "
| sort() | \n", "in alphabetical order, but for numbers it will go ascending | \n", "
| index() | \n", "find the index of the first occurrence of a specified element | \n", "
| count(m,a(optional),b(optional)) | \n", "number of occurrences of m within the substring indicated by a and b | \n", "
\n",
"
\n",
"