I’m not sure I understand your question, but I think you need a list of subjects and a dictionary for each subject. The result would be something like this:
[{"nome": "Matemática",
"serie": "quinto ano",
"professor": "Paulo",
"alunos":[{"nome": "Maria Antônia", "media": 7}, {"nome":"Renato", "media": 8}],
"mediaTotal":7.5},
{"nome": "Matemática",
"serie": "sexto ano",
"professor": "Rosa",
"alunos":[{"nome": "Suzana", "media": 7}, {"nome":"Claudia", "media": 8}],
"mediaTotal":7.5}]
To build this structure, I thought of a code like this:
nMaterias = int(input("digite o número exato de matérias que há nessa série"))
materias = []
for i in range(nMaterias):
materia = {
"nome": input("Qual o nome da matéria %s: " %(i+1)),
"serie": input("Qual a série da matéria %s: " %(i+1)),
"professor": input("Qual o nome do professor da matéria %s: " %(i+1)),
"alunos": None,
"mediaTotal": input("Qual a média da matéria %s: " %(i+1)),
}
materias.append(materia)
print (materias)
Well, of course it would take a bigger job to make another loop to fill each student and the total average could be done with a fast calculation of the filled averages.
Also, in your code, you cannot store print() in a variable. First you store the input in the variable and then you give a print command().
Java or python?
– gato
python..........
– Genezis
the question editing is something common here in the OS, I think there is no need to edit the question thanking someone for editing the question. : s
– Wilker
Okay then! .....
– Genezis
From what I understand you want to store a list of subjects as string, would that?
– gato
yes, and that....
– Genezis
As you have already noticed by the answers you had: yes, it is possible. But your question is not very good for the format of this site because it is too wide. You can do what you want in countless ways, including creating graphical interfaces (which would be more appropriate for a large amount of input data). I suggest specifying the question further (if your question is how to loop to read multiple console entries, do that one question directly).
– Luiz Vieira