+ 1
How to take multiple values from user and create a dictionary
Python dictionary
8 Answers
+ 1
I find it still unclear what specific structure of data you want to eventually have.
+ 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.
0
Thanks for the input ... I have four keys like roll number, student name, marks, subject.. How should i add other two inputs...
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...
0
How to add more values to dict...
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:")
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 ...
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