• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Python by
Q:
What is the major difference between tuples and lists in Python?

1 Answer

0 votes
by
There are several major differences between tuples and lists in Python, which include the following:

Tuples

Tuples are similar to a list, but they are enclosed within parenthesis, unlike the list.

The element and size can be changed.

They cannot be updated.

They act as read-only lists.

Tuples are surrounded by ( )

Example of Tuple Code is, tup = (1, "a", "string", 1+2)

Lists

The list is used to create a sequence.

The element and size cannot be changed.

They can be updated.

They act as a changeable list.

Lists are surrounded by [ ]

Example of Lists Code is, L = [1, "a" , "string" , 1+2]

Related questions

0 votes
asked Jun 11, 2020 in Python by Robindeniel
0 votes
asked Aug 29, 2020 in Python by Robindeniel
...