Truthy or Falsy?

Easy ⏱ 8 min 82% acceptance ★★★★★ 4.6
Write a function is_truthy(value) that returns True if value would be treated as truthy in an if value: check, and False otherwise. Do not hardcode a list of values — rely on Python's own truthiness rules via bool().

Examples

Example 1
Input
is_truthy(0)
Output
False
Explanation

The integer 0 is falsy.

Example 2
Input
is_truthy([])
Output
False
Explanation

An empty list is falsy.

Example 3
Input
is_truthy("0")
Output
True
Explanation

A non-empty string is truthy, even "0".

Constraints

  • `value` can be any Python object.

Topics

Variables & Data Typesboolean coercion

Companies

NetflixSwiggy

Hints

Hint 1

`bool(value)` already implements this.

Hint 2

Empty containers, 0, 0.0, None, and False are the falsy values.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.