The following content is provided under a Creative
Commons license.
Your support will help MIT OpenCourseWare
continue to offer high quality educational resources for free.
To make a donation or view additional materials
from hundreds of MIT courses, visit MIT OpenCourseWare
at ocw.mit.edu.
ANA BELL: So the question is, we have
the string s is the string 600 is 6 triple 1 and 6 triple 2.
So we're going to create the string here.
It's initially an empty string.
I want to mention that the plus equals-- for example,
if I say a plus equals 1.
This is equivalent to a is equal to a plus 1.
We've seen this a couple of times before-- last lecture
and the last lecture before that.
So all this means here, this line here,
is we're going to take the previous string that we have,
and we're just going to add it to itself,
plus the last letter.
So the first thing we're going to have is going to be new_str
is equal to 2.
Then this line here is going to say now I'm
going to add to the two that I already have,
the element at position 0, which is a 6.
So I'm going to have 6.
Then I'm going to add to that, the element at index 4.
So I'm starting count from 0.
So this is 0, 1, 2, 3, 4.
So that's a space.
And I'm going to go-- notice I have 4, and then
nothing in the middle.
So my stop is going to be length s by default.
And I'm going to take every 30 characters.
Now every 30 is longer than the actual string I have.
So we're just going to end at the end of the string.
So the next thing that we're going to add is a space.
And then the last thing we're doing here
is we're starting at 13.
So now I'm going to have to count 13-- 0, 1, 2, 3, 4, 5, 6,
8, 9, 10, 11, 12, 13.
That's the 1.
I'm going to go backward, because of this minus 1.
And I'm going to go backward until 10, but right
before 10-- so 1 less than 10.
So I'm going to do 100.
So this one, this 0, and then this 0.
Then I'm going to print this new string.
I think this is right.
If you paste it into Spider, it should give you 26 space 100.
So I think most of the class got it right.
I think, yes.
Perfect.