Use Python ternary operator to improve code.