Length Of Tuple Python
Now, we are quite familiar with how we can create tuples in our program. Now, Let’s have a look at how we can get the length of the tuple. Well, the length of the tuple is nothing but the number of elements/items in the tuple. To get the length of a tuple, we can simply make use of the len function, which takes an object (like a tuple, list, string, etc.) as an argument, and returns the length of the object.
Length Of Tuple Python
Here is a simple program, which demonstrates how we can get the length of a tuple.
As you can see in the above program, we have a simple tuple, and then we are trying to get the length of our tuple. We are passing the object to the len function, and it is returning the length of the tuple, which is nothing but the number of elements in the tuple. After that, we are printing the length of the tuple. You can try executing the above program and also try for some other tuples. There are times when we need to have the length of the tuple. In such situations, you can use the len function.