Created
July 17, 2021 22:25
-
-
Save Mo-Shakib/cc1e4f7780c2057388e28d96537c8548 to your computer and use it in GitHub Desktop.
Python - Removes all the elements from a linked list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clear(self): | |
while (self.head is not None): | |
temp = self.head | |
self.head = self.head.next | |
temp = None | |
print('All the elements has been cleared!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment