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
  • 39,467
  • 16
  • 112
  • 140
André
  • 25
  • 5

1 Answers1

1

You can use str.partition:

>>> '1;2 | 2;4'.partition("|")
('1;2 ', '|', ' 2;4')
Asocia
  • 5,935
  • 2
  • 21
  • 46