Difference between List and Tuples

Difference between List and Tuples in Python

Comparison between List and Tuples in Tabular Form

  • Lists and Tuples are very important data structures in Python.
  • The Key Difference between List and Tuples is that the List is written in square brackets [ ] while Tuples are written in round brackets ( ). 
  • Also, List is Mutable and Tuple is immutable.
  • In Python List is just like an array.
List and Tuples Difference
List and Tuples Difference

Comparison Chart

List Tuples
1 List is mutable Tuples are immutable
2 List iteration is slower and time-consuming. Tuples iteration is faster.
3 List is performed well in insertion and deletion operations. Tuples are performed well in accessing elements operations.
4 List takes more memory Tuples take less memory.
5 Lists are many built-in methods Tuples are less in-built methods.
6 In List Error is more likely to happen. In Tuples Error hardly takes place.
7 Lists can be used to store homogeneous and heterogeneous elements. Tuples are used to store only heterogeneous elements.




List

  • Syntax of List:
    • list_num = ['1', '2', '3, '4', '5']
  • Example of List:

    • list_num = ['1', '2', '3','4','5']
      print(list_num)
    • Output: [‘1’, ‘2’, ‘3’, ‘4’, ‘5’]

Tuples

  • Syntax of Tuples

    • tuple_num = ('1', '2', '3', '4', '5')
  • Example of Tuples

    • tuple_num = ('1', '2', '3', '4', '5')
      print(tuple_num)
    • Output: (‘1’, ‘2’, ‘3’, ‘4’, ‘5’)

More Difference