Student list

Run Settings
LanguagePython
Language Version
Run Command
def add_student(student_list, student): student_list.append(student) #append is a list's function def remove_student(student_list, student_id): student_list = [s for s in student_list if s['id']!=student_id] #!= is not equal return student_list def update_student(student_list, student_id, new_info): for student in student_list: if student['id']==student_id: student.update(new_info) #update is a dict's function students=[ #original dict {'id':1,'name':'Alice', 'age':20}, {'id':2,'name':'Bob', 'age':22}, {'id':3,'name':'Charlie', 'age':23} ] update_student(students,2,{'name':'Robert', 'age':23}) #replace #2 student's info/data print(students) new_student={'id':4,'name':'David','age':21} add_student(students, new_student) #insert a dict print(students) students=remove_student(students,2) #remove a row wrt # print(students)
Editor Settings
Theme
Key bindings
Full width
Lines