January 2019
Beginner
318 pages
8h 23m
English
We cannot remove individual tuple elements. So, to remove an entire tuple explicitly, use the del statement. Refer to the following example:
#!/usr/bin/python3cities = ('Mumbai', 'Bangalore', 'Chennai', 'Pune')print ("Before deleting: ", cities)del citiesprint ("After deleting: ", cities)Output:Before deleting: ('Mumbai', 'Bangalore', 'Chennai', 'Pune')Traceback (most recent call last):File "01.py", line 5, in <module>print ("After deleting: ", cities)NameError: name 'cities' is not defined
Read now
Unlock full access