A tuple is a collection of ordered and immutable elements enclosed in parentheses () and separated by commas ,. To create a tuple in python, you can simply enclose the elements within parentheses as follows:
main.py40 chars2 lines
In the code above, we create a tuple my_tuple that contains integers and strings. To access the elements of a tuple, you can use indexing where the first element is at index 0. For example:
main.py73 chars3 lines
gistlibby LogSnag