{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lecture 2—List and Collection" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Version 1.0. Prepared by [Makzan](https://makzan.net), 2020 June." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In last lecture, we learn to store values into variables. There were `int`, `float`, `string`, `boolean`. They are all singular value. In this notebook, we learn to store a collection of values by using `list`, `tuple`, `dictionary`, and `Named Tuple`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Table of Content\n", "\n", "- [List](#List)\n", "- [Exercise: List creation, insert, and remove](#Exercise:-List-creation,-insert,-and-remove)\n", "- [Slicing](#Slicing)\n", "- [Tuple](#Tuple)\n", "- [Dictionary](#Dictionary)\n", "- [Exercise: Using Dictionary](#Exercise:-Using-Dictionary)\n", "- [Exercise: Slicing](#Exercise:-Slicing)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## List" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can create list by using `[ ]` brackets. Then we separate each item by comma. For example: the following create a list with 4 items." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[1,2,3,4]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need a variable to store the list. Otherwise, we cannot reference the list anymore." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "sample_list = [1,2,3,4]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Count and Sum the list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are basic built-in list functions: `len`, `max`, `min`, `sum`." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(sample_list)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "max(sample_list)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "min(sample_list)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum(sample_list)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2.5" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum(sample_list)/len(sample_list)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following example create a list that stores 5 names." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "names = ['Thomas', 'Steven', 'Jane', 'Tom', 'Susan']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By using `len()`, we know that there are 5 items in the list." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(names)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Index of List" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](list-visualized.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can get individual item from the list by using `[index]`. The index begins with 0.\n", "\n", "|0|1|2|3|4|\n", "|-|-|-|-|-|\n", "|Thomas|Steven|Jane|Tom|Susan|\n", "\n", "\n", "|-5|-4|-3|-2|-1|\n", "|-|-|-|-|-|\n", "|Thomas|Steven|Jane|Tom|Susan|\n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Thomas'" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names[0]" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Steven'" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names[1]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Susan'" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names[-1]" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Tom'" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names[-2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Appending items to list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can append new item to the end of the list." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "names.append(\"John\")" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Thomas', 'Steven', 'Jane', 'Tom', 'Susan', 'John']" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also insert item into any position of the list. For example, we can insert item to the beginning by using index `0`." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "names.insert(0, \"Peter\")" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Peter', 'Thomas', 'Steven', 'Jane', 'Tom', 'Susan', 'John']" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sometimes, we will need to append multile items at once. We can do so by using `extend` function." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "names.extend(['Victoria', 'Terence', 'Eric', 'Nicolas', 'Thomas'])" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Peter',\n", " 'Thomas',\n", " 'Steven',\n", " 'Jane',\n", " 'Tom',\n", " 'Susan',\n", " 'John',\n", " 'Victoria',\n", " 'Terence',\n", " 'Eric',\n", " 'Nicolas',\n", " 'Thomas']" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we need to remove an item, we can use `remove` and provide the item value." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "names.remove('Thomas')" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Peter',\n", " 'Steven',\n", " 'Jane',\n", " 'Tom',\n", " 'Susan',\n", " 'John',\n", " 'Victoria',\n", " 'Terence',\n", " 'Eric',\n", " 'Nicolas',\n", " 'Thomas']" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we know the index of the item, we can use `del` to delete the item by using index. Beware that `del` is not a function. There is no `( )` when using `del`." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "del names[1]" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Peter',\n", " 'Jane',\n", " 'Tom',\n", " 'Susan',\n", " 'John',\n", " 'Victoria',\n", " 'Terence',\n", " 'Eric',\n", " 'Nicolas',\n", " 'Thomas']" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise: List creation, insert, and remove\n", "\n", "Assuming now we want to store a list of cities. They are:\n", "\n", "'Macao', 'Beijing', 'Helsinki', 'Kyoto', 'Sydney'" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "# Your code here\n", "cities = None\n", "cities" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Expected result |\n", "| --- |\n", "| ['Macao', 'Beijing', 'Helsinki', 'Kyoto', 'Sydney'] |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we want to append city \"Hong Kong\" to last of the list. Please use `append()` to append the item." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "# Your code here\n", "None\n", "\n", "cities" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Expected result|\n", "| --- |\n", "| ['Macao', 'Beijing', 'Helsinki', 'Kyoto', 'Sydney', 'Hong Kong'] |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we want to prepend city \"Shanghai\" to the first of the list. Please use `insert()` to prepend the item." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "# Your code here\n", "None\n", "\n", "cities" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Expected result|\n", "| --- |\n", "| ['Shanghai', 'Macao', 'Beijing', 'Helsinki', 'Kyoto', 'Sydney', 'Hong Kong'] |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we want to append a list of cites to the current `cities` list. We can use `extend()` to do so. Given the following `new_cities` list." ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "new_cities = ['London', 'Stockholm', 'Sao Paulo']" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# Your code here\n", "None\n", "\n", "cities" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Expected result|\n", "| --- |\n", "| ['Shanghai', 'Macao', 'Beijing', 'Helsinki', 'Kyoto', 'Sydney', 'Hong Kong', 'London', 'Stockholm', 'Sao Paulo'] |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Slicing\n", "\n", "Given a list **L**, we can extract individual item by using `L[index]` where index begins with 0. For example, `L[0]` to get the first item, `L[-1]` to get the last item.\n", "\n", "We can also extract a range of items by using slicing. The syntax is `[ start : end : step ]`.\n", "\n", "The range includes the `start` index and exclude the `end` index." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "sample_list = [1,2,3,4,5,6,7,8,9,10]" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5]" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[0:5]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Item at index 1—3 (index begins with 0)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[2, 3, 4]" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[1:4]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Item at index 1, 3" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[2, 4]" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[1:4:2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can omit 0 for the starting index. For example, this gets the first 5 items." ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5]" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[:5]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Items from beginning to last 5th item." ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[:-5]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to omit the end value to indicate until-the-end. For example, this gets the last 3 items." ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[8, 9, 10]" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[-3:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Every second item from beginning to end" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 3, 5, 7, 9]" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[::2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A copy of the whole list" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A copy of the whole list, in reversed order" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list[::-1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Tuple" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Tuple is the read-only version of list. We can express a tuple by using `( )`." ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "sample_tuple = (1,2,3,4,5,6,7,8,9,10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can read the Tuple as same as reading List. But we cannot modify the Tuple." ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_tuple[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Dictionary\n", "\n", "Dictionary is a collection of key-value pairs. We can express a dictionary by using `{ }` with keys and values inside.\n", "\n", "It is useful to collect information for the same subject together in one place. For example, we can store a student profile inside a dictionary. The benefit is that we can " ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "sample_dict = {\n", " 'name': 'Thomas', \n", " 'score': 65\n", "}" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'name': 'Thomas', 'score': 65}" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_dict" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can store dictionaries inside a list. Indeed, an “item” in collection can be another collection. So we can put dictionary inside list. Or we can put list inside dictionary." ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "students = [\n", " {'name': 'Thomas', 'score': 65},\n", " {'name': 'Alan', 'score': 95},\n", " {'name': 'Jane', 'score': 85},\n", " {'name': 'Susan', 'score': 75},\n", " {'name': 'Chris', 'score': 45}\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here is another example that put a list as value inside dictionary." ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "student_a = {\n", " 'name': 'Steven',\n", " 'email': 'steven@example.com',\n", " 'classes': [\n", " 'Introducing Python',\n", " 'Web scraping with BeautifulSoup',\n", " 'Plotting graph with MatPlotLib'\n", " ]\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise: Using Dictionary\n", "\n", "Assuming now we want to store data of book. There are 3 attributes for each book. They are `title`, `category`, `price`.\n", "\n", "Please create a `book` varibale to store the following book.\n", "\n", "|title|category|price|\n", "|---|---|---|\n", "|Python Tricks|Programming|240|" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "book = None\n", "book" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|{'title': 'Python Tricks', 'category': 'Programming', 'price': 240}|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we want to store a list of books. Here is the books data:\n", "\n", "|title|category|price|\n", "|---|---|---|\n", "|Python Tricks|Programming|240|\n", "|Python Crash Course|Programming|200|\n", "|Getting Real|Startup|200|" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[None, None, None]" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "book_a = None\n", "book_b = None\n", "book_c = None\n", "\n", "books = [\n", " book_a,\n", " book_b,\n", " book_c\n", "]\n", "\n", "books" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "[\n", "{'title': 'Python Tricks', 'category': 'Programming', 'price': 240},\n", "{'title': 'Python Crash Course', 'category': 'Programming', 'price': 200},\n", "{'title': 'Getting Real', 'category': 'Startup', 'price': 200}\n", "]\n", "||" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise: Slicing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assuming now we have a list of numbers" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "sample_list = [1,2,3,4,5,6,7,8,9,10]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How to get the last item in the list?" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|10|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How to get last 3 items in the list?" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|[8, 9, 10]|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How to get the first 3 items in the list?" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|[1, 2, 3]|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 🤖 Boss Level" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now assume we have a list of books." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "books = [\n", " {'title': 'Python Tricks', 'category': 'Programming', 'price': 240},\n", " {'title': 'Python Crash Course', 'category': 'Programming', 'price': 200},\n", " {'title': 'Getting Real', 'category': 'Startup', 'price': 200}\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How to get the first book title?" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "result_1 = None\n", "\n", "result_1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|Python Tricks|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How to get the price of last book?" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "result_2 = None\n", "\n", "result_2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|200|" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Sorry! Your results are incorrect.\n" ] } ], "source": [ "def hello_boss(result_1, result_2):\n", " if result_1 == \"Python Tricks\" and result_2 == 200:\n", " print(\"Congratulations! You passed Lesson 2 Collection.\")\n", " elif result_1 == \"Python Tricks\":\n", " print(\"Sorry! Your result 2 is incorrect.\")\n", " elif result_2 == 200:\n", " print(\"Sorry! Your result 1 is incorrect.\")\n", " else:\n", " print(\"Sorry! Your results are incorrect.\")\n", " \n", "hello_boss(result_1, result_2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "|Expected result|\n", "|---|\n", "|Congratulations! You passed Lesson 2 Collection.|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Summary\n", "\n", "In this notebook, we learned the essential techniques to store a series of data into list. Next, we will take a look at logic-flow with if-condition and for-loop." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 2 }