1

I'm try to split text from string, but I can't.

I have 1;2 | 2;4, for example in my string, and I want to:

['1;2', '|', '2;4']

codeforester
  • 34,080
  • 14
  • 96
  • 122
André
  • 25
  • 5

1 Answers1

1

You can use str.partition:

>>> '1;2 | 2;4'.partition("|")
('1;2 ', '|', ' 2;4')
Asocia
  • 5,441
  • 2
  • 19
  • 42