Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. previous = None # `previous` initially points to None
  2. current = p # `current` points at the first element
  3. following = current.dalsi # `following` points at the second element
  4.  
  5. # go till the last element of the list
  6. while current:
  7. current.dalsi = previous # reverse the link
  8. previous = current # move `previous` one step ahead
  9. current = following # move `current` one step ahead
  10. if following: # if this was not the last element
  11. following = following.dalsi # move `following` one step ahead
  12.  
  13. p = previous
  14. return p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement