If an operation succeeds, it should return a value; if it fails, it should return a different value.
1Times asked
Jun 2026Last seen
Jun 2026First seen
💡 Model Answer
A common pattern is to return a tuple or an object that contains both the result and a status flag. For example, in Python you could return (True, result) on success and (False, error_message) on failure. Alternatively, use exceptions for error paths and return the value only on success. This makes the caller’s logic clear: check the status before using the result.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500