$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #87

Which fix removes the bug?

cfg = {'host': 'x'}
port = cfg['port']
  1. Read it safely: cfg.get('port', 80)
  2. Read it safely: cfg.fetch('port', 80)
  3. Wrap the dict in list(cfg) first
  4. Change the key to cfg['Port'] here
Bracket access raises KeyError for a missing key; get() returns a default.
Play Problem Solving ▸