fork download
  1. # your code goes here
  2. # 定义列表数据
  3. score_list=[65, 92, 78, 90, 45, 83, 57, 96]
  4. # 先要定义好字典的键值对
  5. score_dict = {
  6. 'high': [],
  7. 'middle': [],
  8. 'low': []
  9. }
  10. # 循环遍历
  11. for score in score_list :
  12. # 验证
  13. if score >= 90:
  14. score_dict[ 'high'].append(score)
  15. elif score >= 60:
  16. score_dict[ 'middle'].append(score)
  17. else:
  18. score_dict['low'].append(score)
  19. # 打印字典
  20. print(score_dict)
Success #stdin #stdout 0.06s 14024KB
stdin
Standard input is empty
stdout
{'high': [92, 90, 96], 'middle': [65, 78, 83], 'low': [45, 57]}