Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 19 Online
OpenStudy (anonymous):

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?

hartnn (hartnn):

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. )

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!