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

回答編集履歴

3

ソース修正

2020/08/24 03:17

投稿

yureighost
yureighost

スコア2183

answer CHANGED
@@ -4,7 +4,7 @@
4
4
  ```python
5
5
  with open('test.txt', mode='r', encoding='utf-8') as f:
6
6
  score = [[s[0], int(s[1])] for s in [line.rstrip().split(' ') for line in f]]
7
- print(score)
7
+ print(f'score = {score}')
8
8
 
9
9
  '''
10
10
  [['英語', 80], ['数学', 90], ['国語', 70], ['理科', 80], ['社会', 70]]

2

ソース修正

2020/08/24 03:17

投稿

yureighost
yureighost

スコア2183

answer CHANGED
@@ -4,7 +4,7 @@
4
4
  ```python
5
5
  with open('test.txt', mode='r', encoding='utf-8') as f:
6
6
  score = [[s[0], int(s[1])] for s in [line.rstrip().split(' ') for line in f]]
7
- print(score)
7
+ print(score)
8
8
 
9
9
  '''
10
10
  [['英語', 80], ['数学', 90], ['国語', 70], ['理科', 80], ['社会', 70]]

1

ソース修正

2020/08/24 03:15

投稿

yureighost
yureighost

スコア2183

answer CHANGED
@@ -3,8 +3,8 @@
3
3
  元データはテキストから読み込むものだと思うのでそのように実装しました。
4
4
  ```python
5
5
  with open('test.txt', mode='r', encoding='utf-8') as f:
6
- l = [[s[0], int(s[1])] for s in [line.rstrip().split(' ') for line in f]]
6
+ score = [[s[0], int(s[1])] for s in [line.rstrip().split(' ') for line in f]]
7
- print(l)
7
+ print(score)
8
8
 
9
9
  '''
10
10
  [['英語', 80], ['数学', 90], ['国語', 70], ['理科', 80], ['社会', 70]]