Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. list1=[13,13,13,1,2,13,14,15,16,13,13,44,13,13,13]
  2.  
  3. for i,e in enumerate(list1):
  4. if i+2 == len(list1):
  5. break
  6. if list1[i] == 13 and list1[i+1] == 13 and list1[i+2]==13:
  7. list1.pop(i)
  8. list1.pop(i+1)
  9. elif list1[i] == 13 and list1[i+1] == 13 and list1[i+2]!=13:
  10. list1.pop(i)
  11.  
  12. while 13 in list1:
  13. if list1[-1] == 13:
  14. list1.pop()
  15. print(list1)
  16. else:
  17. trzyn=list1.index(13)
  18. list1.pop(trzyn+1)
  19. list1.pop(trzyn)
  20.  
  21. print(sum(list1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement