回答編集履歴

3

修正

2023/07/25 23:05

投稿

ForestSeo
ForestSeo

スコア2720

test CHANGED
@@ -1,31 +1,17 @@
1
1
  `return`すると、関数は終了してしまいます。
2
-
3
2
  ```python
4
-
5
3
  def transaction(transact_log):
6
-
7
4
  for item in transact_log:
8
-
9
5
  sender = item[0][0]
10
-
11
6
  receiver = item[0][1]
12
-
13
7
  send_amount = item[1]
14
-
15
8
  intermediary = item[2]
16
-
17
9
  transact_fee = item[3]
18
-
19
10
  yield sender, receiver, send_amount, intermediary, transact_fee
20
11
 
21
-
22
-
23
12
  result = transaction(transact_log=[(('player1', 'player2'), 800, 'inter1', 4), (('player3', 'player4'), 200, 'inter2', 2)])
24
-
25
13
  result = list(result)
26
-
27
14
  print(result)
28
-
29
15
  # [('player1', 'player2', 800, 'inter1', 4), ('player3', 'player4', 200, 'inter2', 2)]
30
-
16
+ ```
31
- ````yield`を使うと、上のようできます。
17
+ `yield`を使うと、上のようできます。

2

更新

2021/12/19 03:38

投稿

ForestSeo
ForestSeo

スコア2720

test CHANGED
@@ -22,7 +22,9 @@
22
22
 
23
23
  result = transaction(transact_log=[(('player1', 'player2'), 800, 'inter1', 4), (('player3', 'player4'), 200, 'inter2', 2)])
24
24
 
25
+ result = list(result)
26
+
25
- print(list(result))
27
+ print(result)
26
28
 
27
29
  # [('player1', 'player2', 800, 'inter1', 4), ('player3', 'player4', 200, 'inter2', 2)]
28
30
 

1

更新

2021/12/19 03:38

投稿

ForestSeo
ForestSeo

スコア2720

test CHANGED
@@ -26,4 +26,4 @@
26
26
 
27
27
  # [('player1', 'player2', 800, 'inter1', 4), ('player3', 'player4', 200, 'inter2', 2)]
28
28
 
29
- ```yield
29
+ ````yield`を使うと、上のようできます。