I'm doing some Homework and the question is: Write a Python Generator that walks through the nodes of a linked list.
Hint: Use yield.
class Node:
pass
def my_generator():
start = Node()
point = start
point.data = 1
print(point.data)
point.next = Node()
point = point.next
point.data = 2
print(point.data)
point.next = Node()
point = point.next
point.data = 3
print(point.data)
point.next = Node()
point = point.next
point.data = 4
print(point.data)
point.next = None
I'm relatively new to Python, and I've spent the last 2 days trying to figure out how to use Yield in this piece of code.I understand I could do this way easier by using other options in Python but this is the set question for my homework. Thank you