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

質問編集履歴

3

main.pyのコメント、空白の見直しで再記述したところ、期待道理の結果になりました。ありがとうござました

2026/04/10 21:46

投稿

sanchunaka
sanchunaka

スコア36

title CHANGED
File without changes
body CHANGED
@@ -36,17 +36,14 @@
36
36
  ```main.py
37
37
  with open('student.csv', 'r') as f:
38
38
  student = {}
39
-
40
39
  # ファイル全てを読み込む
41
40
  data = f.readlines()
42
-
43
41
  for line in data:
44
42
  # カンマで[name, score]となるリストに区切る
45
43
  line = line.strip().split(",")
46
44
  name = line[0]
47
- score = int(line[1])
45
+ score = int(line[1])
48
46
  student[name] = score
49
-
50
47
  print(student)
51
48
  ```
52
49
 

2

Elizabeth -> Elizabeth,10に修正

2026/04/10 02:58

投稿

sanchunaka
sanchunaka

スコア36

title CHANGED
File without changes
body CHANGED
@@ -65,7 +65,7 @@
65
65
  Patricia,80
66
66
  Linda,70
67
67
  Barbara,90
68
- Elizabeth
68
+ Elizabeth,10
69
69
  Jennipher,50
70
70
  Maria,35
71
71
  Margaret,55

1

student.csvの修正

2026/04/10 02:25

投稿

sanchunaka
sanchunaka

スコア36

title CHANGED
File without changes
body CHANGED
@@ -51,20 +51,27 @@
51
51
  ```
52
52
 
53
53
  ```student.csv
54
+ Smith,60
54
- with open('student.csv', 'r') as f:
55
+ Johnson,100
56
+ William,80
57
+ Jones,65
58
+ Brown,30
59
+ Davis,20
60
+ Miller,90
61
+ Willson,70
62
+ Moore,60
63
+ Taylor,100
64
+ Mary,80
65
+ Patricia,80
66
+ Linda,70
67
+ Barbara,90
68
+ Elizabeth
55
- student = {}
69
+ Jennipher,50
70
+ Maria,35
71
+ Margaret,55
72
+ Dorothy,40
73
+ Lisa,70
56
74
 
57
- # ファイル全てを読み込む
58
- data = f.readlines()
59
-
60
- for line in data:
61
- # カンマで[name, score]となるリストに区切る
62
- line = line.strip().split(",")
63
- name = line[0]
64
- score = int(line[1])
65
- student[name] = score
66
-
67
- print(student)
68
75
  ```
69
76
 
70
77
  ### 試したこと・調べたこと