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 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
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,140 points
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,140 points
+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,140 points
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
+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
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

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.