File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,14 @@ isn't exactly like mine but it works just fine it's ok, and you can
27272 . The broken code has mostly the same issues as exercise 1. Here are
2828 the problems that excercise 1 doesn't have:
2929
30+ - The if-elif-else has a blank line at a confusing place. Delete it.
31+ - After deleting the code, it looks quite dense. Add a new blank
32+ line before the ` if ` .
3033 - The elif line is missing a ` : ` at the end.
3134 - On the last line the comma is on the wrong side. ` "bla bla," ` is
32- a string that ** contains** a comma, but ` "bla bla", ` is a
33- string and a ** separate** comma. In this exercise, the last
34- line should be
35- ` print("I don't know what", something, "means.") `
35+ a string that ** contains** a comma, but ` "bla bla", ` is a
36+ string and a ** separate** comma. In this exercise, the last
37+ line should be ` print("I don't know what", something, "means.") `
3638
37393 . We can simply ask the word with input and print ` word * 1000 ` .
3840
Original file line number Diff line number Diff line change @@ -245,7 +245,20 @@ else:
245245Now the ` else ` belongs to the ` if 1 == 2 ` part and ** it has nothing to
246246do with the ` if 1 == 1 ` part** . On the other hand, the elif version
247247** grouped the multiple ifs together** and the ` else ` belonged to all of
248- them.
248+ them. Adding a blank line makes this obvious:
249+
250+ ``` python
251+ if 1 == 1 :
252+ print (" hello" )
253+
254+ if 1 == 2 :
255+ print (" this is weird" )
256+ else :
257+ print (" world" )
258+ ```
259+
260+ In general, adding blank lines to appropriate places is a good idea. If
261+ you are asked to "fix code", feel free to add missing blank lines.
249262
250263## Summary
251264
@@ -276,6 +289,7 @@ them.
276289 something = input (" Enter something: " )
277290 if something = ' hello' :
278291 print (" Hello for you too!" )
292+
279293 elif something = ' hi'
280294 print (' Hi there!' )
281295 else :
You can’t perform that action at this time.
0 commit comments