+ 1

How to take multiple values from user and create a dictionary

Python dictionary

20th Jan 2020, 1:16 PM
Venkatesh Sarivisetty
Venkatesh Sarivisetty - avatar
8 Respostas
+ 1
I find it still unclear what specific structure of data you want to eventually have.
20th Jan 2020, 2:27 PM
HonFu
HonFu - avatar
+ 1
You can make a list as value. students = { "Sven" : ["math 3", "english 3"] } Or you can build a nested dict in dict students = { "Sven" : { "Math" : 3, "English" : 3 } } Dont give up, you can solve this.
20th Jan 2020, 6:40 PM
Sven_m
Sven_m - avatar
0
Thanks for the input ... I have four keys like roll number, student name, marks, subject.. How should i add other two inputs...
20th Jan 2020, 1:24 PM
Venkatesh Sarivisetty
Venkatesh Sarivisetty - avatar
0
Values are from not from.. keys can be given to users as input and values will be taken by them... Based t On that i need to create a dict...
20th Jan 2020, 1:30 PM
Venkatesh Sarivisetty
Venkatesh Sarivisetty - avatar
0
How to add more values to dict...
20th Jan 2020, 1:51 PM
Venkatesh Sarivisetty
Venkatesh Sarivisetty - avatar
0
n = int(input('"how many entries you want to add to dict:")) dic = dict() for i in range(n): dic["key{}".format(i)] = input("value:")
20th Jan 2020, 4:58 PM
MedG
MedG - avatar
0
Actually i have text file where all values are exist like rollno studentname marks and subject as columns and values as rows. So what ever the data he entered can be converted into dictionary ...
20th Jan 2020, 5:42 PM
Venkatesh Sarivisetty
Venkatesh Sarivisetty - avatar
0
Also the would like to sum up the marks for same student and print... Also need to save a file name seperately for each student with his roll number in the file name... Eg. Roll no 101 and student name is venkat file name is like venkat.101. txt
20th Jan 2020, 5:44 PM
Venkatesh Sarivisetty
Venkatesh Sarivisetty - avatar