teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2018/11/02 06:32

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -7,6 +7,7 @@
7
7
  > ```
8
8
 
9
9
  タイポです。`resonse` ⇒ `response`
10
+ また、今回のエラーとは直接の繋がりは無いですが、`respone`と打っている箇所も有りますね。
10
11
 
11
12
  ```Python
12
13
  >>> def func(cond):

1

追記

2018/11/02 06:32

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -6,4 +6,19 @@
6
6
  return response
7
7
  > ```
8
8
 
9
- タイポです。`resonse` ⇒ `response`
9
+ タイポです。`resonse` ⇒ `response`
10
+
11
+ ```Python
12
+ >>> def func(cond):
13
+ ... if cond:
14
+ ... a = 42
15
+ ... return a
16
+ ...
17
+ >>> func(True)
18
+ 42
19
+ >>> func(False)
20
+ Traceback (most recent call last):
21
+ File "<stdin>", line 1, in <module>
22
+ File "<stdin>", line 4, in func
23
+ UnboundLocalError: local variable 'a' referenced before assignment
24
+ ```