[Python] Tuples?

Tuples are used to store multiple items in a single variable. Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage. A tuple is a collection which is ordered and unchangeable.


whenever create tuples, we're using open and close parenthesis()

coordinates = (2, 5)

print(coordinates[1])

You're going to get "5" 



What's the difference between List and Tuple ?


List                     vs                  Tuple

  [ ]                                                 ( )   

Changeable                        Unchangeable 


Python Collections (Arrays)

There are four collection data types in the Python programming language:

  • List is a collection which is ordered and changeable. Allows duplicate members.
  • Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
  • Set is a collection which is unordered, unchangeable*, and unindexed. No duplicate members.
  • Dictionary is a collection which is ordered** and changeable. No duplicate members.


you can also combine Tuple and List 
coordinates = [(2, 5), (7,8), (3,4)]

print(coordinates[1])


you're getting;
(7, 8)

Popular posts from this blog

[Python] Dictionary

[Visual Design 2/3]

[JavaScript] For loop , Function