How to make a tuple in Python

preview_player
Показать описание
Tuples are *technically* just immutable lists, but by convention we tend to use tuples and lists for quite different purposes.

00:00 Making tuples in Python
00:15 Tuples are like lists, but immutable
00:39 Tuples are all over the place
01:03 The parentheses are optional: it's the commas that make the tuple
01:37 When should you make a tuple?
02:56 Returning multiple values from a function
03:27 Summary
Рекомендации по теме
Комментарии
Автор

Awesome teaching format !!! Thank you for your pedagogy and generosity for sharing it with the rest of the world. Ne Blessed and Successful in all your actions, Sir. Salutations from France.

xyzxyz
Автор

Say we have a tuple, that is technically immutable:
t = 1, [2, 3], 5
t[1].append(4) # now we are changing one of the items of this tuple
print(t)
(1, [2, 3, 4], 5)
# by id(t) it will be the same (original so to say) tuple 😃Not so immutable, right?

samoylov
visit shbcf.ru