Python Tuples
Tuples are Somewhat Unique to Python.
A Tuple is a Sequence of Immutable Python Objects.
Unlike Lists, Tuples cannot be Changed.
A Tuple is Created by placing Values inside of Parentheses, Separated by Commas.
Tuples are Typically Assigned a Variable Name.
Do Not begin Variable Names with a Number... Guaranteed Error!
Example:
Beware... A Single Element Tuple must be followed a Comma! example: single_tuple = (value1,)
Unlike other Programming Languages...
Python Tuples can Contain any type of Object: Numbers, Strings, Even other Tuples
They just cannot be Changed!
Accessing Tuples
The Tuple Items are Stored and Accessed based on Index... Starting with Index 0.
Here are Some Examples of Accessing Tuple Items:
Manipulating Tuples
Manipulating a Tuple is Not Possible.
You cannot Change, Delete, or Sort the Values of a Tuple.
But... You can add Values.
See Combining Tuples Below.
Combining Tuples
Merging or Combining Tuples is Simple.
Note... You cannot add a List to a Tuple.
Here are Some Examples of Combining Tuples: