Skip to content

Commit f3afec5

Browse files
authored
Add solution to Document This in Episode 18 Programming Styles
1 parent 17ea81d commit f3afec5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

episodes/18-style.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,32 @@ average(values)
151151
> return values[1]
152152
> ~~~
153153
> {: .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:
171+
> > ~~~
172+
> > help (middle)
173+
> > Help on function middle in module __main__:
174+
> > middle(a, b, c)
175+
> > Return the middle value of three.
176+
> > Assumes the values can actually be compared.
177+
> > ~~~
178+
> > {: .python}
179+
> {: .solution}
154180
{: .challenge}
155181
156182
> ## Clean Up This Code

0 commit comments

Comments
 (0)