How to split string with limit by the end in Python

python, split, string

Solution

Use `str.rsplit` specifying maxsplit (the second argument) as `1`:

>>> "hello.world.foo.bar".rsplit('.', 1) # <-- 1: maxsplit
['hello.world.foo', 'bar']

Problem

I have the following string: `"hello.world.foo.bar"` and I want to split (with the `"."` as delimiter, and only want to get two elemets starting by the end) this in the following: `["hello.world.foo", "bar"]` How can I accomplish this? exist the limit by the end?

Original source