Quick question on Tuples and Lists: obviously they are similar in some ways and the main difference seems to be that Tuples are immutable while Lists are mutable. Can anyone explain if somehow having an immutable type would be helpful at some stage and whether that is why Tuples exist in the first place and why we don't just have lists?
1) Tuples are easier and computationally "lightweight" than lists. -If you just want to iterate/traverse through a set of data (without modifying it), use a tuple. 2) Tuples can be used as keys to the dictionary (Lists can't be used as it can be modified) 3) Tuples make your code safer as you're using a "write-protected" data which you never want to change (example : empolyee id no., student id no.,licence no., etc. etc. etc. )
Join our real-time social learning platform and learn together with your friends!