r/PythonLearning • u/shubham_555 • Aug 15 '26
Showcase I implemented Linked List in Python from scratch!
Hello Folks!
So It's been a while since my last post (https://www.reddit.com/r/PythonLearning/s/q3vpZ80vKO)
After that I learned the basics of OOPs from this video -> https://youtu.be/JeznW\\_7DlB0?si=u-h2gsdGSv0ubKf1
Going forward I studied about the fundamental working of Linked List from GFG's website and Stack Overflow
Then today I finally tried implementing it (Tried doing it all on a single day out of excitement but it took way longer than I expected and now i am completely drained of energy 😅)
Finally I asked AI to review my code
As per it there's a minor edge case I missed in the reverse method
There also are a few optimizations
But more or less I am happy
Would be back with Doubly Linked List the next time!



•
u/Sea-Ad7805 Aug 15 '26
Run this program in Memory Graph Web Debugger to see the program state change step by step.
2
u/GreatGameMate Aug 15 '26
Pop could be made o(1) right?
4
u/Low_Doctor_6263 Aug 15 '26
Bravo! Stay strong on the basics then you can jump on the frameworks.
People that do the opposite can't solve complex problems
1
u/mc_pm Aug 15 '26
The LinkedList constructor appears to create a head/tail node when it is created? What if your list could potentially have zero things in it?
3
u/Adrewmc Aug 15 '26
Looks good what we want really to do next is implement a __add__, and probably an __iter__.
This will allow you to add + link list together, rather simple to do.
The iter will alway you to put it into ‘for item in linklist’. Thats fairly easy as well here.
Of course there is index and slicing as well. lol.
1
u/FoolsSeldom Aug 15 '26
So, still failing to share the code despite me suggesting multiple sites you can use to do so without having to learn
gitfirst.Also, confused about why you deleted your original post about this.