In this Python Tutorial we cover the basics of the Python tuple if you need more information visit our website at http://learnpythontutorial.com/basics...
If you have any questions leave a comment and we will help you out.
Do not forget to subscribe
Fundamentals of the Python Tuple
In this Python tutorial, we will discuss the basics of the Python tuple which is another data type in the Python programming language. This is a brief introduction to Python tuples and they will be covered in full in a later section.
What is a Tuple?
A tuple is similar to a list but a tuple cannot be amended after it has been created which makes tuples immutable. Tuples are a sequence like a list so we would use the index to call our values. Tuples I would say are not used as much as list or dictionaries but they do bring some of their own value to the game since tuples cannot change after being created that helps protect the content from being overwritten or changed when our program runs. If your content will not change throughout the life of the program runs then use a tuple and if the content will change or has the possibility to change then you need to go to a list.
What is the Tuples Syntax?
We show to Python that we need to utilize a tuple by utilizing brackets( ) and much the same as list we separate information by commas.
Tuple Syntax
var = (213, 5643, "Red", "Blue")
var1 = ("TV", "light", "Cam", "Seat")
Some Tuple Examples
Underneath we will make a few tuples and appoint them to a variable. Take after along in your Python translator and when you are finished with our tuple cases attempt some all alone.