Skip to content

London | 26-SDC-Jul | AYK | Sprint 2 | Implement a linked list in Python - #262

Open
sarawone wants to merge 1 commit into
CodeYourFuture:mainfrom
sarawone:AYK_Linked_List
Open

sarawone wants to merge 1 commit into
CodeYourFuture:mainfrom
sarawone:AYK_Linked_List

Conversation

@sarawone

Copy link
Copy Markdown

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

Hello!

Thank you for your time. Please help me by checking the code for the implementation of LinkedList in Python.
Kindly provide feedback.

Thanks,
AYK

@sarawone sarawone added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 18, 2026
Comment on lines +1 to +6
#node class to hold value and pointer
class Node:
def __init__(self,data):
self.data = data
self.next = None # pointer to next node
self.prev = None # pointer to previous node

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Common practice is to keep a spacing between parameters. Prettier does not support Python, you would probably need to install a different formatter for Python.

  • Could consider using docstrings instead of comments do document a class/function.

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

def push_head(self,data):
new_node = Node(data)

if not self.head: #if the node is empty it will have both head & tail

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 condition could also evaluate to True if self.head is False. Could you look up a more suitable and preferred syntax to check if a value is None?

  • A small suggestion: try to avoid comments that simply restate what the code already makes clear. In this case, the code is self-explanatory, so the comment doesn't really add any new information. Comments are most useful when they explain why something is done, clarify non-obvious behaviour, or document an important assumption. This helps keep the code clean and makes the comments that we do have more valuable.

Comment on lines +37 to +42
if self.head == self.tail:
self.head = None
self.tail = None
else:
self.tail = self.tail.prev
self.tail.next = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 19, 2026
@cjyuan

cjyuan commented Oct 19, 2026

Copy link
Copy Markdown

Note: The PR description is missing a Changelist section.

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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants