Hi. I seem to get the work done by using lists in python but I want to know when to use tuples and when to use lists. Why use tuples at all , when you can get the job done using lists?
Lists and tuples are similar to some extent, but differ in their applications. Lists are mutable where are tuples are immutable. So, once you define a tuple, you can not make changes to individual element.
Sure, you can get the same thing done from Lists as well, but lists being mutable typically takes longer processing time as compared to tuples. The difference can make a big impact, if you are doing similar operation multiple times.
Hope this helps.