Here are my instructions, followed by my code. I am having trouble figuring out how to create an empty list to put the students into (a roster) and then of course how to remove students from that list.
The Course class should have the following methods:
__init__
takes and stores a single integer course number.get_course_number
takes no arguments and returns the integer course number.add_student
takes a single string student name and adds it in a roster.drop_student
takes a single string student name. If the student is currently in the roster, it removes that student name from the roster and returns nothing.get_roster
takes no arguments and returns a list containing the names of all students enrolled in the course in alphabetical order.
This is what I have written so far:
class Course(object):
def __init__(self,course_number):
self.course_number = int(course_number)
def get_course_number(self):
print (self.course_number)
def add_student(self, student):
self.list=[]
self.student= student
self.list.append(student)
def drop_student(self, student_id):
self.student_id= student_id
if student_id in self.student:
del self.student[student_id]
def get_roster(self):
print (sorted(self.student))
Any insight is much appreciated!