$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #105

Which fix removes the bug?

if user.get('role') is 'admin':
    grant()
  1. Compare by value: == 'admin' instead
  2. Compare by value: in 'admin' instead
  3. Change .get('role') to ['role']
  4. Wrap the value in str() before the test
is compares object identity, which is unreliable for strings built at runtime.
Play Problem Solving ▸