If I'm expecting a key-value pair separated by a colon, and a line doesn't have a colon, how does this error manifest?

Responsive Ad Header

Question

Grade: Education Subject: Support
If I'm expecting a key-value pair separated by a colon, and a line doesn't have a colon, how does this error manifest?
Asked by:
118 Viewed 118 Answers

Answer (118)

Best Answer
(280)
If you have a line like `setting=value` and try to unpack it with `key, value = line.split(':')`, since the colon is missing, `line.split(':')` returns `['setting=value']`. Trying to unpack this single-element list into `key` and `value` will trigger the 'expected 2 got 1' error.