回答編集履歴
1
追記
test
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
|
7
7
|
for i in range(2):
|
8
8
|
|
9
|
-
b.append(tk.Button(root, text=str(i), command=lambda i=i:print(i)))
|
9
|
+
b.append(tk.Button(root, text=str(i), command=lambda i=i: print(i)))
|
10
10
|
|
11
11
|
```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
**参考**: [ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか?](https://docs.python.org/ja/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result)
|