+ 1
Lists vs Tuples
I know what both are. lists are ordered and changeable and and allow duplicates and tuples are ordered and immutable and allow duplicates. I just cant figure which one to use to do something. They both have the same definitions. LITERALLY. if you look up what lists/tuples python in google it will give you the same defintion. Im asking when to use which?
5 odpowiedzi
+ 6
The main difference is that you cannot change the tuple once you've created it.
So if you want to add, change or remove data, you better go for a list than for a tuple.
+ 1
Lisa Thanks, I thought i was doing it wrong but i got it now 👌
+ 1
Although what Lisa said about tuples is correct, there are still ways in which you can edit tuples
+ 1
Lamron
You would have to create a new tuple/ overwrite the previous one. Or something more hacky. 😉
+ 1
Lisa yes, which is a pain... Inefficient