I'm learning linked lists and to print it, my instructor used the following code but didn't explain it:
def __iter__(self):
node = self.head
while node:
yield node
node = node.next
print([node.value for node in singlyLinkedList])
I'm confused why 'while node' works and 'while True' throws an error.