Skip to content

London | 26-Jul-SDC |Shaghayegh far | Sprint 2 | Implement a linked list - #245

Open
shaghayeghfar wants to merge 2 commits into
CodeYourFuture:mainfrom
shaghayeghfar:implement_linked_list
Open

shaghayeghfar wants to merge 2 commits into
CodeYourFuture:mainfrom
shaghayeghfar:implement_linked_list

Conversation

@shaghayeghfar

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 linked list in Python with push_head, pop_tail, and remove. All tests passed.

@shaghayeghfar shaghayeghfar added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 13, 2026

@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.

Could consider adding type hints to each method to clearly specify the types of its parameters and return value.

Comment on lines +1 to +5
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.previous = 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.

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

Comment on lines +32 to +37
if self.head == self.tail:
self.head = None
self.tail = None
else:
self.tail = self.tail.previous
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 13, 2026
@shaghayeghfar

Copy link
Copy Markdown
Author

Dear @cjyuan ,
Thank you so much for taking the time to review my code and share your helpful feedback.
I've followed your suggestions and updated the code. Thanks again for helping me learn and improve.

@shaghayeghfar shaghayeghfar 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 14, 2026

@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.

self.previous = None
__slots__ = ("value", "next", "previous")

def __init__(self, value: str) -> None:

@cjyuan cjyuan Oct 14, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Limiting the value to be of type str would make the linked list less flexible -- could not be reused for different typesof data.

Suggestion: Explore the topic "Generics" in Python. You could ask AI this:

In Python, how to ensure a parameter (and its storage) maintains a consistent type $T$ throughout a class?

Note: Python 3.12+ introduce a new syntax which make specifying generic type easier.

No change needed

@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 14, 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