Difference between Lists and Tuples

Total Post:113


 512  View(s)
Rate this:

What is the difference between Lists and Tuples? give an example also.

  1. Re: Difference between Lists and Tuples


    The list is a datatype available in Python which can be written as a list in using comma ,separated items between square brackets[]. Important thing about a list is that items in a list need not be of the same type. they can be edited. 

    list1 = ['Mind','Stick', 2008, 2018]; 
    list2 = [1, 2, 3, 4, 5 ];
    list3 = ["a", "b", "c", "d"]

    Many type of built-in list function are occurred- 

    * cmp(list1, list2) 






    Tuples are just like lists.The differences between tuples and lists are, the tuples cannot be changed unlike lists means can't be edited and tuples use parentheses,whereas lists use square brackets (). 

    tup1 = ('Mind', 'Stick', 2008, 2018); 
    tup2 = (1, 2, 3, 4, 5 );
    tup3 = "a", "b", "c", "d";

    Many type of built-in Tuples function are occurred- 

    *cmp(tup1, tup2) 





    we can perform operation in Lists and Tuples both is shown below: 




    I hope, It will be helpful for you.

    Happy Coding :)


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.