You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/18-style.md
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,35 @@ average(values)
106
106
> return highest
107
107
> ~~~
108
108
> {: .python}
109
+
> >
110
+
> > ## Solution
111
+
> >
112
+
> > These two lines will show up in online help:
113
+
> >
114
+
> > ~~~
115
+
> > '''Determine overall maximum edit distance.'''
116
+
> > '''Avoid checking sequence against itself.'''
117
+
> > ~~~
118
+
> > {: .python}
119
+
> >
120
+
> > This line will not be made available because it is not in the docstring format: `"Find maximum edit distance between multiple sequences."` Docstrings should reside within the function definition, using three single quotes.
121
+
> >
122
+
> >
123
+
> > There is one syntax error:
124
+
> > ~~~
125
+
> > Traceback (most recent call last):
126
+
> > File "<interactive input>", line 1, in <module>
127
+
> > File "<module2>", line 11, in overall_max
128
+
> > NameError: global name 'edit_distance' is not defined
129
+
> > ~~~
130
+
> > {: .python}
131
+
> >
132
+
> > The `edit_distance` function has not been defined:
133
+
> > ~~~
134
+
> > this = edit_distance(left, right)
135
+
> > ~~~
136
+
> > {: .python}
137
+
> {: .solution}
109
138
{: .challenge}
110
139
111
140
> ## Document This
@@ -122,6 +151,32 @@ average(values)
122
151
> return values[1]
123
152
> ~~~
124
153
> {: .python}
154
+
> >
155
+
> > ## Solution
156
+
> >
157
+
> > Change the `#` to `'''` to change to docstring:
158
+
> >
159
+
> > ~~~
160
+
> > def middle(a, b, c):
161
+
> > ''' Return the middle value of three.
162
+
> > Assumes the values can actually be compared.
163
+
> > '''
164
+
> > values = [a, b, c]
165
+
> > values.sort()
166
+
> > return values[1]
167
+
> > ~~~
168
+
> > {: .python}
169
+
> >
170
+
> > Calling `help` on the `middle` function now shows the docstring:
0 commit comments