File tree 2 files changed +21
-5
lines changed
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
27
27
2 . The broken code has mostly the same issues as exercise 1. Here are
28
28
the problems that excercise 1 doesn't have:
29
29
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 ` .
30
33
- The elif line is missing a ` : ` at the end.
31
34
- 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.") `
36
38
37
39
3 . We can simply ask the word with input and print ` word * 1000 ` .
38
40
Original file line number Diff line number Diff line change @@ -245,7 +245,20 @@ else:
245
245
Now the ` else ` belongs to the ` if 1 == 2 ` part and ** it has nothing to
246
246
do with the ` if 1 == 1 ` part** . On the other hand, the elif version
247
247
** 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.
249
262
250
263
## Summary
251
264
@@ -276,6 +289,7 @@ them.
276
289
something = input (" Enter something: " )
277
290
if something = ' hello' :
278
291
print (" Hello for you too!" )
292
+
279
293
elif something = ' hi'
280
294
print (' Hi there!' )
281
295
else :
You can’t perform that action at this time.
0 commit comments