Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Tuple basics
3. Defining a tuple with one or zero elements
Tuples in functions
Summary

Instruction

Good job! There are two special cases for defining tuples. If you want to create an empty tuple, you must use empty parentheses parentheses:

empty_tuple = ()

What if you want to create a tuple with a single item? You may use parentheses parentheses or not, but you must include a trailing comma:

single_item_tuple = (1,)

Without the comma, single_item_tuple will be an ordinary integer – even if you surround it with parentheses parentheses.

When you print such a tuple, the trailing comma will also be displayed.

print(single_item_tuple)

Result: (1,)

Exercise

Create a tuple named from_city with a single item: 'Paris'. Then print its value to the console.

Stuck? Here's a hint!

Remember about the trailing comma.