We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def getNode(llist, positionFromTail):
"""
find length of list
position from head = length - position from tail
iterate again, if traversals = position, print value
"""
length, traversals = 0,0
current = llist
while current:
length += 1
current = current.next
positionFromHead = length-positionFromTail-1
for i in range(positionFromHead):
llist = llist.next
return llist.data
Get Node Value
You are viewing a single comment's thread. Return to all comments →
Python3 soln: