A one-element tuple, also called a singleton tuple, contains exactly one object. Write a trailing comma inside the parentheses: (5,). The comma creates the tuple; parentheses alone do not. section 10.1
Adding one word to a tuple
In a Scrabble word search, all_valid_words = all_valid_words + (words[start:end],) adds one newly found word to the existing tuple. The comma is required because the extracted word is a single element. section 19.2
Compare these tuple forms:
- () is an empty tuple; (1, 2, 3) contains three objects; ("tickets") is just a parenthesized string; ("carnival",) is a singleton tuple. section 10.1
- A singleton tuple can also hold a value while building a larger tuple, as in found_words = found_words + (word,). section 19.2
