Read a Settings Line

Python for AIMedium+10 XP+10

Read a Settings Line

A settings file has lines like volume = 7. Each line has a key, an =, and a value.

Task: write parse_setting(line) that returns a list [key, value].

  • Split at the first = only. The value can contain more = signs, and they stay in the value.
  • Remove whitespace from both ends of the key and of the value.
  • If the line has no = at all, return [the whole line trimmed, ""].

Examples

line = "volume = 7"
returns ['volume', '7']
line = "formula = a=b+c"
returns ['formula', 'a=b+c']

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run