I am trying to create a student mark list. Firstly, i have to create both student and course list. However, i'm stuck at this problem. Here is my code:
from datetime import datetime
class StudentMark():
class Student():
def studentCount(student):
student.count = int (input ("Enter number of students: "))
return student.count
def studentDetail(student):
student.sID = input ("Student id: ")
student.sName = input ("Student name: ")
student.sDOB = input("Student's DOB:")
student.setDOB=datetime.strptime(student.sDOB, "%d/%m/%Y")
return student.sID, student.sName, student.setDOB
def studentList(student):
sList = []
for i in range(student.count):
sList.append ((student.sID, student.sName, student.setDOB))
sList.sort()
for s in sList:
print (f"Student id: {s[0]} Name: {s[1]} Date of birth: {s[2]}")
class Course():
def courseCount(course):
course.count = int (input ("Enter number of courses: "))
return course.count
def courseDetail(course):
course.cID = input ("Course id: ")
course.cName = input ("Course name: ")
return course.cID, course.cName
def courseList(course):
cList = []
for i in range(course.count):
cList.append ((course.cID, course.cName))
cList.sort()
for c in cList:
print (f"Course id: {c[0]} Name: {c[1]}")
std = Student()
std.studentCount()
std.studentDetail()
std.studentList()
crs = Course()
crs.courseCount()
crs.courseDetail()
crs.courseList()
When i want to input 2 and more than 2 datas. For example:
Enter number of students: 2
Student id: 111
Student name: max
Student's DOB:11/11/1111
Student id: 111 Name: max Date of birth: 1111-11-11 00:00:00
Student id: 111 Name: max Date of birth: 1111-11-11 00:00:00
Enter number of courses: 2
Course id: 1
Course name: math
Course id: 1 Name: math
Course id: 1 Name: math
As you can see, the outputs are repeated and i don't know how to fix this problem. Hope everyone can help me how to solve it.