Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb61b52d

Browse files
authored
Merge pull requestalexmojaki#2 from alexmojaki/spamegg1-lists
Tables
2 parentsb536999 +37f95c5 commitb61b52d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

‎backend/main/chapters/c06_lists.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,13 @@ class negative_index_concatenation_exercise(VerbatimStep):
920920
921921
You might realize that working with the last element via `x[len(x) - 1]` is a bit cumbersome.
922922
The same can be achieved by `x[-1]`.
923-
Similarly, the second to last element `x[len(x) - 2]`is equivalent to `x[-2]`, and so on.
923+
Similarly, the second to last element `x[len(x) - 2]`can be written as `x[-2]`, and so on.
924924
Python allows us to count the index backwards too, starting at the last element with `-1`:
925925
926-
# TODO: table goes here explaining negative indexing
926+
| Index | First elt. | Second elt. | Third elt. | ... | 2nd to last elt. | Last elt. |
927+
|-----------|------------|-------------|-------------|-----|------------------|------------|
928+
| Forwards | `0` | `1` | `2` | ... | `len(x) - 2` |`len(x) - 1`|
929+
| Backwards | `-len(x)` |`-len(x) + 1`|`-len(x) + 2`| ... | `-2` | `-1` |
927930
928931
Next exercise:
929932
@@ -1124,7 +1127,10 @@ class mutation_string_append(VerbatimStep):
11241127
Again these two methods also work on strings similar to how they work on lists.
11251128
`index` returns the *beginning index* of the search word `'the'` in the longer string
11261129
`'feed the dog and the cat'`, which is `5`.
1127-
TODO: table goes here explaining string index
1130+
1131+
| 0 | 1 | 2 | 3 | 4 | **5** | 6 | 7 | 8 | ... |
1132+
| :--: | :--: | :--: | :--: | :--: | :---: | :--: | :--: | :--: | :--: |
1133+
| f | e | e | d | | **t** | h | e | | ... |
11281134
11291135
Note that in most cases, methods which *modify a list in place* (`append`, `insert`, `remove`) merely return `None`,
11301136
while the remaining functions/methods return a new useful value without changing the original argument.

‎backend/main/utils/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def highlight_node(node, text):
190190

191191

192192
defhighlighted_markdown(text):
193-
returnmarkdown(text,extensions=[HighlightPythonExtension()])
193+
returnmarkdown(text,extensions=[HighlightPythonExtension(),'tables'])
194194

195195

196196
defshuffled(it):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp