How to Check if a List, Tuple or Dictionary is Empty in Python

The preferred way to check if any list, dictionary, set, string or tuple is empty in Python is to simply use an if statement to check it. For example, if we define a function as such: [python] def is_empty(any_structure): if any_structure: print(‘Structure is not empty.’) return False else: print(‘Structure is empty.’) return True [/python] It […]

Read More

Catching Python Exceptions – The try/except/else keywords

Often times when coding a python masterpiece, there are certain things that could go wrong when executing your masterfully designed code. Things such as files or directories that are missing, empty strings, variables that are supposed to be strings but are actually arrays at run-time. These things are called exceptions in Python. This is what […]

Read More