Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- previous = None # `previous` initially points to None
- current = p # `current` points at the first element
- following = current.dalsi # `following` points at the second element
- # go till the last element of the list
- while current:
- current.dalsi = previous # reverse the link
- previous = current # move `previous` one step ahead
- current = following # move `current` one step ahead
- if following: # if this was not the last element
- following = following.dalsi # move `following` one step ahead
- p = previous
- return p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement