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

Which fix removes the bug?

if 'admin' or 'root' in roles:
    grant()
  1. Group it: ('admin' or 'root') in roles
  2. Use and instead of or between them
  3. Test each: 'admin' in roles or 'root' in roles
  4. Call roles.contains('admin', 'root') on the list
It parses as 'admin' or ('root' in roles), and the non-empty string 'admin' is always truthy.
Play Problem Solving ▸