Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. def formatLines(lst):
  2. result = lst[0]
  3. count = 0
  4. for item in lst:
  5. count = count + 1
  6. if count == 5:
  7. count = 0
  8. result = result + "\n" + item
  9. else:
  10. result = result + " "
  11. result = result + item
  12. return result
  13.  
  14.  
  15.  
  16. output:
  17.  
  18. words_3.txt
  19. body body cold ence four
  20. from into just late less
  21. life live man
  22. more more
  23. more more more pain pain
  24. part race rest rest some
  25. some sons take take than
  26. than than that that they
  27. this this when with with
  28. with with
  29.  
  30. expected output:
  31.  
  32. words_3.txt
  33. age all and and and
  34. and and and and and
  35. but but can dav eit
  36. end ers for for fre
  37. gen has has his his
  38. man men not off old
  39. one sex six six the
  40. the the the the the
  41. the the the the the
  42. the the
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement