Skip to content

Commit db78306

Browse files
authored
Update 11-lists.md Working With the End exercise
Fix an error in the Working With the End exercise. If a string has N elements, the most negative index that can be safely used is -N not -(N-1), corresponding to the [0] index. >>> element = 'helium' >>> print(element[-1]) m >>> N = len(element) >>> print(N) 6 >>> print(element[-(N-1)]) #This will give us the [1] index (e) e >>> print(element[-(N)]) h
1 parent 858046e commit db78306

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

_episodes/11-lists.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ IndexError: string index out of range
277277
> > ~~~
278278
> > {: .output}
279279
> > 1. A negative index begins at the final element.
280-
> > 2. `-(N - 1)` corresponds to the first index, which is the [0] index.
280+
> > 2. `-(N)` corresponds to the first index, which is the [0] index.
281281
> > 3. It removes the final element of the list.
282282
> > 4. You could do the following: `print(values[0:-1])`
283283
> {: .solution}

0 commit comments

Comments
 (0)