Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Advaitgaur004 committed Oct 25, 2024
1 parent 0a555f0 commit 737be04
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions demo/src/student_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ def add_student(self, roll_no, name, age, grade):
Bug: Function doesn't properly check for duplicate roll numbers
It compares strings instead of integers for roll numbers
"""
# Bug: Incorrect string comparison instead of integer comparison
if any(str(student.roll_no) == str(roll_no) for student in self.students):
return False, "Roll number already exists"
roll_no = int(roll_no)

for student in self.students:
if student.roll_no == roll_no:
return False, "Student with this roll number already exists"


new_student = Student(roll_no, name, age, grade)
self.students.append(new_student)
Expand Down

0 comments on commit 737be04

Please sign in to comment.