Comparing Values: == and is
~9 mincode completion
Write that returns:
"missing"when the value is"empty"when it is an empty list"present"for anything else, including 0 and an empty string
Examples
None is missing
- Input
- describe(None)
- Output
- "missing"
An empty list is empty
- Input
- describe([])
- Output
- "empty"
Zero is a real value, so it is present, not missing
- Input
- describe(0)
- Output
- "present"
Hints
Hint 1
Work directly with the arguments value and return the result rather than printing it.
Hint 2
Watch for this: used falsy check for none.
Requirements
value: anything, possibly NoneReturn "missing" for None, "empty" for [], "present" otherwise.
Constraints
Standard library only, no imports required
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Where this shows up
~9 min
••••••
3 employers weight this skill
2 frontier labs, 1 AI product company. Top match scores 80.
Python
def describe(value):
"""
Classify a value as missing, empty, or present.
Args:
value: anything, possibly None
Returns:
"missing" for None, "empty" for [], "present" otherwise.
"""
# YOUR CODE HERE
pass