What is the difference between list and tuple?

0 votes
Really confused on these data types. Whats is the advantage of on over the other?
May 4, 2018 in Python by anto.trigg4
• 3,420 points
1,817 views
list is mutable because it can modified value but tuple cannot modified value so it is immutable.

1 answer to this question.

0 votes

Lists are mutable(values can be changed) whereas tuples are immutable(values cannot be changed).

You can consider the Lists as Arrays in C, but in List you can store elements of different types, but in Array all the elements should of the same type whereas a Tuple is a sequence of immutable Python objects. Tuples are sequences, just like Lists. The differences between tuples and lists are:
1) Tuples cannot be changed unlike lists
2) Tuples use parentheses, whereas lists use square brackets. Consider the example below:

Countries = ('India', 'US', 'UK')

Now you must be thinking why Tuples when we have Lists?
So the simple answer would be, Tuples are faster than Lists. If you’re defining a constant set of values which you just want to iterate, then use Tuple instead of a List. 
All Tuple operations are similar to Lists, but you cannot update, delete or add an element to a Tuple.

answered May 4, 2018 by aayushi
• 750 points

Related Questions In Python

+1 vote
2 answers

What is the difference between classes and labels in machine learning?

Classes and Labels both are almost same things ...READ MORE

answered Apr 3 in Python by SA
• 1,030 points
120 views
0 votes
1 answer

What is the difference between Python and IPython?

There are few differences between Python and ...READ MORE

answered Jul 26, 2018 in Python by Priyaj
• 56,940 points
479 views
0 votes
1 answer

What is the difference between re.search and re.match?

The theoritical approach can be this way, re.match is ...READ MORE

answered Aug 10, 2018 in Python by Priyaj
• 56,940 points
1,139 views
+1 vote
1 answer

What is the difference between range and xrange functions in Python 2.X?

xrange only stores the range params and ...READ MORE

answered Aug 22, 2018 in Python by Priyaj
• 56,940 points
280 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 346 views
+4 votes
6 answers
0 votes
2 answers

What is the use of Python language?

python is general purpose programming language.it very ...READ MORE

answered Mar 15 in Python by rajesh kumar
49 views
0 votes
1 answer

What is the use of raw_input function in Python?

raw_input fuction is no longer available in ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
120 views