下記の通りに動くプログラムを作りたいのですが、やり方がどうしてもわかりません。
助言をいただけたら嬉しいです。
Alice -> 190
Bob -> 172
Charlie -> 185
Masami -> 173
Dave -> 169
Eve -> 150
Masato -> 170
students_dic = { # 名前, 身長, 体重 'Alice':{'height':190, 'weight':49.5}, 'Bob':{'height': 172, 'weight': 63.0}, 'Charlie': {'height':185,'weight':77.9}, 'Masami':{'height': 173, 'weight':80.1}, 'Dave':{'height': 169, 'weight':70.7}, 'Eve': {'height': 150, 'weight':45.3}, 'Masato': {'height': 170, 'weight': 60.2}, } print(students_dic) def print_height(sdict): pass #ここから私が書いたコードです。 height_dic = {'190','172','185','173','169','150','170'} for k,h in students_dic.items(): print(f'{k} -> {h}') #ここまで # 機能確認のために関数を実行! print_height(students_dic)
> リストから要素を抽出する方法
「リスト」とはどれのことを指していますか?
回答1件
あなたの回答
tips
プレビュー