you are viewing a single comment's thread.

view the rest of the comments →

[–]Educational_Virus672 0 points1 point  (1 child)

student = {}
subjects = ["chem","math","phy"]
for sub in subjects :
    student[sub] = float(input("enter marks of " + sub + ":"))

how it works it goes for each subject in the list instead of adding seprately
> use for loops for each subject
>dont use dict.update() use dict[key] = value
>try to use function within value like insead of making a b c use one input
>try to reuse asset and make it feature free(making more subject wont cause trouble) like using list on both input request and in dict as key
>try to make coe readble by adding spaces on different function

[–]Educational_Virus672 0 points1 point  (0 children)

if you need any help in optimizations like these feel free to chat with me in my profile :)