# Simple Lists

**Channel:** MIT OpenCourseWare
**Source:** https://www.youtube.com/watch?v=zYVWQpCitKQ
**Transcript page:** https://www.withtranscript.ai/video/zYVWQpCitKQ

## Chapters

- 0:00 — Chapter 1 (0:00)

## Transcript

**[0:00]:** The following content is provided under a Creative Common License. Your support will help MIT Open Courseware continue to offer high-quality educational resources for free. To make a donation or view additional materials from hundreds of MIT courses, visit MIT Open Courseware at ocw.mmit.edu.

**[0:23]:** So we have a list L originally life answer 42 and zero and this example if you don't know Hitchhiker's Guide to the Galaxy that's why 42 is important as a as a scientist if I didn't have example one at least one example with the number 42 I'd probably hear about it so here it is okay so we have this original list L which contains the string life the string answer 42 the number 42 and the number zero here I'm writing a loop that iterates over every element directly in L right so I'm so originally thing sorry originally thing is going to be the string life then thing is going to be the string answer then thing is going to be the number 42 and so what am I doing inside the loop as I'm iterating Well, if thing is equal to zero, then I'm going to do this and otherwise I'm going to do this.

**[1:29]:** So for the first two iterations when thing is equal to life or answer, I'm not doing anything. As soon as I hit 42 though, I'm saying L at position one is going to get this value here. Okay. So when I've iterated over this element here, I'm saying L at position one, I'm going to change its value, which says, well, I'm going to keep life the same, but this is going to be everything. And then we're keeping the rest the same, 42 and zero, because we're only modifying L at position one. As soon as we do that, we finish with the loop when L was 42. And then we go through zero. So now thing takes on the value zero and we say if thing is equal to zero well we're good on that. L at position thing is equal to universe. So L at position 0 is equal to universe.

**[2:26]:** So that says okay I'm going to replace life with universe and then everything else stays the same 42 and zero. Okay. So that would be my answer. Universe everything 42 and zero. Great. That's the majority. Good job.
