...

Web Technologies - PYTHON

Back to Course

Lesson Description


Lession - #271 Python Tuples


A Tuple is a collection of Python objects isolated by commas. In someways a tuple is like a list in terms of indexing, nested objects and repetition yet a tuple is unchanging unlike for lists which are changeable.



Let's see a example


# Different types of tuples

# Empty tuple
my_tuple = (>
print(my_tuple>
# Tuple having integers my_tuple = (1, 2, 3>
print(my_tuple>
# tuple with mixed datatypes my_tuple = (1, "Hello", 3.4>
print(my_tuple>
# nested tuple my_tuple = ("mouse", [8, 4, 6], (1, 2, 3>
>
print(my_tuple>

Output


Try it here

python assert

The assert keyword gives you test assuming that a condition access your code returns True, in the event that not, the program will raise an AssertionError. You can compose a message to be composed in the event that the code gets back False