让用户分配列表名称 [英] Letting the User Assign List Names

查看:82
本文介绍了让用户分配列表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个程序,跟踪所有课程中学生的成绩。学生加入课程,并添加课程的不同部分以及如何加权,这就是为什么我计划使用字典。我一直在使用输入函数来允许用户输入每个段的名称。字典可能如下所示:
{homework:.2,tests:.8}
每个课程可能具有不同的权重,甚至不同的段数。所以要跟踪成绩,我想做一个家庭作业列表和一个测试列表,学生可以进入他的成绩。因此,我希望用户输入的列表成为跟踪成绩的名单,因此我可以将学生成绩存储在列表中。思考?或者你能想到一个更好的方法吗?

I am trying to write a program that will keep track of a student's grades in all of his courses. The student adds the course and also adds the different segments of the course and how they are weighted, which is why I was planning on using a dictionary. I've been using an input function to allow the user to enter the name of each segment. The dictionary might look like this: {"homework": .2, "tests": .8} Each course might have different weightings or even a different number of segments. So to keep track of the grades I want to make a homework list and a tests list that the student can enter his grades into. Therefore, I want what the user enters to be the name of the list that keeps track of the grades, so I can store the students grades in a list. Thoughts? Or can you think of a better way of doing this?

推荐答案

数据结构可以嵌套。

{'mylist': [], 'awesomedict': {}}

这篇关于让用户分配列表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆