Mar-20-2017, 06:19 AM
[Image: XalEJUZ][Image: Uy7uE1m]
I'm creating a small Grading System
I had created a Dictionary called Std = {'Ali':[99,80,21],'Ahmed':[]} stands for Students
how the program works?
first you need to register as an admin using Python as a username and 999 as a password (not the best pass ever :))
then you have this welcome String:
print("""
Welcome to Grade System
[1] Enter Grades
[2] to remove a student
[3] to get Average marks
[4] Exit
""")
if you enter 1 the program will ask you to enter the student name then student mark
everything works fine until you enter a student name that does not exist
the program is suppose to create a new student key and append the mark to that student and add it to the Std dictionary.
it creates a new key and assign the mark to it but [Image: 1JQJfVO]
as you see Ahmed and Ali are already created and have multiple values with [] were Ssss is not treated like them and does not have [] on it
at line 16 tell 19 I add this code to create a new Student
else:
print('Student Does not Exist,Will Add it now!')
Std[nameToEnter] = int(gradeToadd)
print(Std)
so how can I insert a new Student with [] surrounding the mark ?
I'm creating a small Grading System
I had created a Dictionary called Std = {'Ali':[99,80,21],'Ahmed':[]} stands for Students
how the program works?
first you need to register as an admin using Python as a username and 999 as a password (not the best pass ever :))
then you have this welcome String:
print("""
Welcome to Grade System
[1] Enter Grades
[2] to remove a student
[3] to get Average marks
[4] Exit
""")
if you enter 1 the program will ask you to enter the student name then student mark
everything works fine until you enter a student name that does not exist
the program is suppose to create a new student key and append the mark to that student and add it to the Std dictionary.
it creates a new key and assign the mark to it but [Image: 1JQJfVO]
as you see Ahmed and Ali are already created and have multiple values with [] were Ssss is not treated like them and does not have [] on it
at line 16 tell 19 I add this code to create a new Student
else:
print('Student Does not Exist,Will Add it now!')
Std[nameToEnter] = int(gradeToadd)
print(Std)
so how can I insert a new Student with [] surrounding the mark ?