avatar Bite 305. Split once, delimit many

Write a function that accepts a string and splits the text on the specified separators, but only on the first occurrence of the delimiter.

For example:

>>> split_once('abc: def: ijk, lmno: pqr - stu, wxy', separators=',-:')
['abc', ' def: ijk', ' lmno: pqr ', ' stu, wxy']

The separators parameter defaults to None if not supplied, in this case you should split on whitespace.

Login and get coding
go back Intermediate level
Bitecoin 3X

44 out of 53 users completed this Bite.
Will you be Pythonista #45 to crack this Bite?
Resolution time: ~65 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help