What is tuple in python and why it is used? How it is different from List in python?
Sign Up to Expert Bucket to ask questions, answer people’s questions, and connect with other people.
Login to Expert Bucket to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A tuple in Python is an immutable sequence of elements. It is similar to a list, but the elements in a tuple cannot be modified once they are created. Tuples are often used to store related data, such as a name and an age, and they can be used as keys in dictionaries because they are immutable. They are created using parentheses, with elements separated by commas. For example:
You can access the elements of a tuple using indexing, just like you would with a list.
Tuples are also commonly used to return multiple values from a function.
Some of the reasons why tuples are used in python are: