Skip to content

NW| 26-Jul-SDC | Ahmad Hmedan | Sprint 2 | Implement a linked list in Python - #227

Open
AhmadHmedann wants to merge 4 commits into
CodeYourFuture:mainfrom
AhmadHmedann:linkedlist
Open

AhmadHmedann wants to merge 4 commits into
CodeYourFuture:mainfrom
AhmadHmedann:linkedlist

Conversation

@AhmadHmedann

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1180

Changelist

Implemented a LinkedList class with push_head, pop_tail, and remove methods.

@AhmadHmedann AhmadHmedann added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 2, 2026
@@ -0,0 +1,60 @@
class LinkedList:
class clsNode:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Look up "Python naming convention for inner class"?

Comment on lines +3 to +6
def __init__(self, value):
self.next = None
self.previous = None
self.value = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest exploring the use of __slots__ to reduce memory usage?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion. I've added __slots__ to reduce memory usage.

Comment on lines +30 to +37
if self.head == self.tail:
self.head = None
self.tail = None
self.size -= 1
return removed_value
self.tail = self.tail.previous
self.tail.next = None
self.size -= 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The .next and .previous were cleared when a node is removed in removed() but not in this method. (Inconsistency)

  • You could consider delegating the node removing task to remove() -- less code to maintain.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. I've updated pop_tail() to reuse the existing remove() method

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 9, 2026
@AhmadHmedann AhmadHmedann added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 11, 2026
@AhmadHmedann
AhmadHmedann requested a review from cjyuan October 11, 2026 09:54

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Well done.

Comment on lines +3 to 5
__slots__ = ("next","previous","value")

def __init__(self, value):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of code formatting, the spacing around the , in the parameter list is not consistent.

Prettier won't work for Python, so you may need to install different formatting tools for Python.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants