October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Check if a Tuple Is Empty in Python

Use `if not t:` to test whether a Python tuple is empty. Learn when to use `len(t) == 0`, how to recognize a one-item tuple, and what truth tests do with other falsy values.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use if not t: to check whether a Python tuple is empty. For example:

if not my_tuple:
    print("The tuple is empty")

Python treats an empty tuple as false in a Boolean test, so this branch runs when the tuple has no items. Python’s built-in types documentation describes this truth-value behavior.

Check a tuple with a truth test

For a tuple named t, write if not t: when the empty case should run, or if t: when the non-empty case should run:

t = ()

if not t:
    print("Empty")
else:
    print("Not empty")

This works because empty sequences are false in a Boolean context. The same rule applies to other empty sequence types, but a truth test does not establish that a value is specifically a tuple.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use len(t) == 0 for an explicit count check

You can also write if len(t) == 0:. Both this and if not t: check whether a tuple has no items. Prefer the truth test for a concise branch; choose the length comparison when spelling out the zero-item condition makes the surrounding code clearer. The cited documentation establishes the truth-test behavior, but not a performance winner between the two forms.

Recognize empty and one-item tuples

The empty tuple can be written as () or created by calling tuple() with no argument. A one-item tuple requires a trailing comma: (item,). Parentheses alone do not turn a single value into a tuple, as explained in the Python tutorial on data structures.

empty = ()
also_empty = tuple()
one_item = (None,)

print(not empty)      # True
print(not also_empty) # True
print(not one_item)   # False

(None,) is not empty: it contains one item, even though that item is None.

Decide what to do with None or other input types

If a value may be None or a type other than tuple, first decide what your function accepts and validate that contract if needed. A truth test returns true for any falsy value, not only an empty tuple. For example, None also makes if not value: run, so that check alone cannot distinguish it from an empty tuple.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Annotate an empty tuple when describing types

In the Python typing specification, tuple[()] denotes the type of an empty tuple. It describes the expected type for static typing; it does not replace a runtime emptiness check such as if not t:. See the typing specification for tuples.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.