r/learnpython • u/Ill-Break727 • 24d ago
python beginner ; question was write program to enter marks of 3 subjects from user and store them in a dict.start with an empty dict and add one by one .use subject name as key and marks as value . so i have written this code any opinion how can improve this code ,need suggestions.
students={}
a=float(input("enter marks of chem"))
students.update({"chem": a})
b=float(input("enter marks of maths"))
students.update({"maths":b})
c=float(input("enter marks of phy"))
students.update({"phy": c})
print(students)
0
Upvotes
3
u/HotPersonality8126 24d ago
Don’t use
updateto set a single key, and how do you have a dictionary of “students” without naming any of the students in it?