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 5, 2018 in Python by anto.trigg4
• 3,440 points
7,023 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 5, 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, 2019 in Python by SA
• 1,090 points
7,732 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
• 58,020 points
4,030 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,125 views
0 votes
2 answers

What is the use of Python language?

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

answered Mar 15, 2019 in Python by rajesh kumar
1,086 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
1,292 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP