+ 1
in python as we have list why we use t-uples?
4 odpowiedzi
+ 8
Why use tuples?
Because they require less processing power from Python because they're immutable.
Doesn't make a big diff in small programmes but if you're working on a big project it will improve speed and efficiency.
Another thing: they are immutable (unlike lists), so they can be used as dictionary keys.
Moreover, tuples can be packed and unpacked. Like this:
tup = 'one' , 'two' , 'three'
_1, _2, _3 = tup
+ 3
Because tuple cannot be modified but list can be modified.Tuple is faster than list both are different.
0
Tuple is value data type, so it is faster. You can also make some good tricks with that:
(a, b) = (b, a)
you can switch values that easy.
0
ok thank you so much