Skip to content

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

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

AhmadHmedann wants to merge 3 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?

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.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants