Sunday, August 19, 2018

Python tuple

Tuple

A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets.

Example

Create a Tuple:
thistuple = ("apple""banana""cherry")
print(thistuple)
Run example »

Example

Return the item in position 1:
thistuple = ("apple""banana""cherry")
print(thistuple[1])
Run example »

Example

You cannot change values in a tuple:
thistuple = ("apple""banana""cherry")
thistuple[1] = "blackcurrant" # test changeabilityprint(thistuple)
Run example »

No comments:

Post a Comment

Top 50 Python proggraming examples with logic

Python Programming Examples The best way to learn any programming language is by practicing examples on your own. You are advised ...