Advertisement
carmennnnn

Untitled

Mar 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. def wordCount(a_list):
  2. return_list = []
  3. counter = 1
  4. return_list.append(len(a_list))
  5. start = 1
  6.  
  7. while start < len(a_list):
  8. if a_list[start] == a_list[start-1]:
  9. counter += 1
  10. start += 1
  11. else:
  12. return_list.append([a_list[start-1], counter])
  13. start += 1
  14. counter = 1
  15.  
  16. return return_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement