Config String Parser

Configs are often stored as one compact string, with key-value pairs separated by delimiters. Given a string s in a format like a=1;b=2;c=3, return a dictionary with string keys and string values. Ignore empty segments. If the same key appears more than once, keep the last value.

Примеры

Ввод
"a=1;b=2;c=3"
Вывод
{"a": "1", "b": "2", "c": "3"}
Ввод
""
Вывод
{}
Ввод
"x=10;;y=20"
Вывод
{"x": "10", "y": "20"}

Нужно реализовать

def parse_config(s):

Теги

stringsdicthashmap
PostgreSQLv16

Tu sa zobrazí výsledok spustenia kódu

Visible tests
1
Input
"a=1;b=2;c=3"
Expected{"a":"1","b":"2","c":"3"}
2
Input
""
Expected{}
3
Input
"x=10;;y=20"
Expected{"x":"10","y":"20"}
4
Input
"k=1;k=2"
Expected{"k":"2"}
5
Input
"host=localhost;port=5432"
Expected{"host":"localhost","port":"5432"}
6
Input
"ab"
Expected{}
Focus radio
Paused · SomaFM · Fluid