Advertisement
RedstoneHair

custom split

Jan 12th, 2023
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. def custom_split(text):
  2.     l = []
  3.     t = []
  4.     for v in text :
  5.         if v == ' ':
  6.             l.append(''.join(t))
  7.             t.clear()
  8.             continue
  9.         # провери да не е \n или \r или всичките тея които не могат да се принтират
  10.         elif some_statement: continue # ама не знам как?
  11.         t.append(v)
  12.     else: l.append(''.join(t))
  13.     return l
  14.  
  15. # работи: "word1  word2" -> ["word1", "", "word2"]
  16. # не работи: "word1  word2\n" -> ["word1", "", "word2\n"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement