|
13 | 13 | "cell_type": "markdown",
|
14 | 14 | "metadata": {},
|
15 | 15 | "source": [
|
16 |
| - "So far we have worked with individual pieces of data like the string `hello`, then with variables we saw how to give this data a name with variables. Well in this lesson, we'll see how we can group data together with lists. " |
| 16 | + "So far we have worked with individual pieces of data like the string `hello`, then with variables we saw how to give this data a name. Well, in this lesson, we'll see how we can group data together with lists. " |
17 | 17 | ]
|
18 | 18 | },
|
19 | 19 | {
|
|
27 | 27 | "cell_type": "markdown",
|
28 | 28 | "metadata": {},
|
29 | 29 | "source": [
|
30 |
| - "A list is our first form of a collection. A collection is just a way of grouping data together, and lists certainly accomplish this. For example, let's consider the top cities to travel to according to Travel and Leisure. We'll see it below, but we must stay focused on Python and data! " |
| 30 | + "A list is our first form of a collection. A collection is just a way of grouping data together, and lists certainly accomplish this. For example, let's consider the top cities to travel to according to Travel and Leisure. We'll see it below, but we must stay focused on Python and data! Here is how we are used to seeing a list of travel locations in a document or on a website." |
31 | 31 | ]
|
32 | 32 | },
|
33 | 33 | {
|
|
53 | 53 | "cell_type": "markdown",
|
54 | 54 | "metadata": {},
|
55 | 55 | "source": [
|
56 |
| - "Ok, and this is how we express this in Python." |
| 56 | + "And here is how that same list looks in Python:" |
57 | 57 | ]
|
58 | 58 | },
|
59 | 59 | {
|
|
91 | 91 | "cell_type": "markdown",
|
92 | 92 | "metadata": {},
|
93 | 93 | "source": [
|
94 |
| - "So we indicate that we are initializing a `list` by placing a bracket, `[` (located above of the return key), and end the list with a closing bracket `']'`. To separate each item in the list, called an element, we place a comma." |
| 94 | + "So we indicate that we are initializing a `list` by placing a bracket, `[`, and end the list with a closing bracket `']'`. To separate each list item, called an element, we place a comma." |
95 | 95 | ]
|
96 | 96 | },
|
97 | 97 | {
|
|
196 | 196 | "cell_type": "markdown",
|
197 | 197 | "metadata": {},
|
198 | 198 | "source": [
|
199 |
| - "Now our `top_travel_cities` list is contains multiple elements. And just like we numbered the elements of a list with text:\n", |
| 199 | + "Now our `top_travel_cities` list contains multiple elements. And just like we numbered the elements of a list with text:\n", |
200 | 200 | "\n",
|
201 | 201 | "1. Solta\n",
|
202 | 202 | "2. Greenville\n",
|
|
294 | 294 | "cell_type": "markdown",
|
295 | 295 | "metadata": {},
|
296 | 296 | "source": [
|
297 |
| - "How would we access the last element, well we could count all of the elements in the list, and `Pyeongchang` would just be one less than that. Or we can ask Python to start from the back in move back one." |
| 297 | + "How would we access the last element? Well, we could count all of the elements in the list, and `Pyeongchang` would just be one less than that. Or we can ask Python to start from the back in move back one." |
298 | 298 | ]
|
299 | 299 | },
|
300 | 300 | {
|
|
583 | 583 | },
|
584 | 584 | {
|
585 | 585 | "cell_type": "code",
|
586 |
| - "execution_count": 40, |
| 586 | + "execution_count": null, |
587 | 587 | "metadata": {},
|
588 |
| - "outputs": [ |
589 |
| - { |
590 |
| - "data": { |
591 |
| - "text/plain": [ |
592 |
| - "'San Antonio'" |
593 |
| - ] |
594 |
| - }, |
595 |
| - "execution_count": 40, |
596 |
| - "metadata": {}, |
597 |
| - "output_type": "execute_result" |
598 |
| - } |
599 |
| - ], |
| 588 | + "outputs": [], |
600 | 589 | "source": [
|
601 | 590 | "top_travel_cities.pop()"
|
602 | 591 | ]
|
603 | 592 | },
|
| 593 | + { |
| 594 | + "cell_type": "markdown", |
| 595 | + "metadata": {}, |
| 596 | + "source": [ |
| 597 | + "The `pop` method is available to call on any list, and removes the last element from the list. As you can see below, calling `pop` removed our last element." |
| 598 | + ] |
| 599 | + }, |
604 | 600 | {
|
605 | 601 | "cell_type": "code",
|
606 | 602 | "execution_count": 41,
|
|
790 | 786 | "name": "python",
|
791 | 787 | "nbconvert_exporter": "python",
|
792 | 788 | "pygments_lexer": "ipython3",
|
793 |
| - "version": "3.6.4" |
| 789 | + "version": "3.6.1" |
794 | 790 | }
|
795 | 791 | },
|
796 | 792 | "nbformat": 4,
|
|
0 commit comments