A tuple is a sequence of values. The values can be any type, and they are indexed by integers, so in that respect tuples are a lot like lists. The important difference is that tuples are immutable as well as a tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets.
For example : ("ayan","dev","apu","symul")
Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also. To access values in tuple, use the square brackets for slicing along with the index or indices to obtain value available at that index.
|
Note : Once a tuple is created, you cannot change its values. Tuples are unchangeable.
You can loop through the tuple items by using a for loop.
|
To determine if a specified item is present in a tuple use the in keyword.
|
python list have built-in methods, methods help us to manipulate tuple items.
|
Python includes many built-in methods but here we just adding some of the following built-in methods to manipulate tuples :
It's a special area where you can find special questions and answers for CSE students or IT professionals. Also, In this section, we try to explain a topic in a very deep way.