Advertisement
Guest User

AnyWayToUsePopWithoutModifyingList

a guest
Jan 24th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. def get_total(list):
  2. total=0
  3. copy=list
  4. while(len(copy) > 0):
  5. total=total+copy.pop(0)
  6. return total
  7.  
  8. def make_list():
  9. list=[1,2,3,4,5]
  10. print("total is ", get_total(list))
  11. print("list is", list)
  12.  
  13.  
  14. make_list()
  15.  
  16. total is 15
  17. list is []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement