質問編集履歴

1

エラーを追記しました

2020/06/23 07:15

投稿

H.JUN
H.JUN

スコア6

test CHANGED
File without changes
test CHANGED
@@ -15,3 +15,75 @@
15
15
  tri_recursion(3)
16
16
 
17
17
  ```
18
+
19
+ エラーです
20
+
21
+ UnboundLocalError Traceback (most recent call last)
22
+
23
+ <ipython-input-2-11463818ac96> in <module>
24
+
25
+ 4 return result
26
+
27
+ 5
28
+
29
+ ----> 6 tri_recursion(3)
30
+
31
+
32
+
33
+ <ipython-input-2-11463818ac96> in tri_recursion(k)
34
+
35
+ 1 def tri_recursion(k):
36
+
37
+ 2 if k > 0:
38
+
39
+ ----> 3 result = k+tri_recursion(k-1)
40
+
41
+ 4 return result
42
+
43
+ 5
44
+
45
+
46
+
47
+ <ipython-input-2-11463818ac96> in tri_recursion(k)
48
+
49
+ 1 def tri_recursion(k):
50
+
51
+ 2 if k > 0:
52
+
53
+ ----> 3 result = k+tri_recursion(k-1)
54
+
55
+ 4 return result
56
+
57
+ 5
58
+
59
+
60
+
61
+ <ipython-input-2-11463818ac96> in tri_recursion(k)
62
+
63
+ 1 def tri_recursion(k):
64
+
65
+ 2 if k > 0:
66
+
67
+ ----> 3 result = k+tri_recursion(k-1)
68
+
69
+ 4 return result
70
+
71
+ 5
72
+
73
+
74
+
75
+ <ipython-input-2-11463818ac96> in tri_recursion(k)
76
+
77
+ 2 if k > 0:
78
+
79
+ 3 result = k+tri_recursion(k-1)
80
+
81
+ ----> 4 return result
82
+
83
+ 5
84
+
85
+ 6 tri_recursion(3)
86
+
87
+
88
+
89
+ UnboundLocalError: local variable 'result' referenced before assignment