Advertisement
zicaentu

split_join

Nov 26th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. s1 = "!"
  2. l1 = ['one', 'two', 'three']
  3.  
  4.  
  5. s2 = s1.join(l1)
  6. print(s2)           # one!two!three
  7.  
  8.  
  9. s3 = "_WoW_".join(l1)
  10. print(s3)           # one_WoW_two_WoW_three
  11.  
  12.  
  13. s4 = "*_*".join(['lala', 'lolo', 'lele'])
  14. print(s4)           # lala*_*lolo*_*lele
  15.  
  16.  
  17. s5 = "".join(['a', 'b', 'c'])
  18. print(s5)           # abc
  19.  
  20.  
  21.  
  22. s6 = "what are you doing?"
  23. l2 = s6.split(" ")
  24. print(l2)           # ['what', 'are', 'you', 'doing?']
  25.  
  26.  
  27. s7 = "one:two:three"
  28. l3 = s7.split(":")  
  29. print(l3)           # ['one', 'two', 'three']
  30.  
  31.  
  32. s8 = "hello world"
  33. l4 = s8.split('o')
  34. print(l4)           # ['hell', ' w', 'rld']
  35.  
  36. s9 = "Hello, mtt, 08.67"
  37. spl = ", "
  38. l5 = s9.split(spl)
  39. print(l5)           # ['Hello', 'mtt', '08.67']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement