Secondary Data Types
Sequence
List
sample_list = [] # declaring a list
sample_list = [1,2,3] # same type values in list
sample_list = [1, 'mixed', True] # mixed list
sample_list = [1, 'mixed', True, [1, False], {'dictionary': 'this is an example'}]
# even other object types like tuple, list, dictionary or even function,
# class instance etc can also be stored within a listAccess an element of a list
sample_list = [1, 'mixed', True, [1, False]]
# can access the content using index, index starts from 0
sample[2] # it gives True
sample[-2] # it also gives True (2nd element from the end)Tuple
Range
Set
Set operations such as union, intersection, and difference are also possible
Mapping
Dictionary
Accessing Values in Dictionary
Listing all keys (first level) in a dictionary
Listing all values in a dictionary
Delete a key from a dictionary
Last updated