Flatten a list of lists in Python

Welcome to a new Python code snippet. In this post, we are going to suggest a couple of methods to flatten a list of lists. The final output is going to be a one dimensional list. Let us take an example: # Given the following list of lists # Write code to flatten it. The

Difference between mutual exclusion and synchronization

Introduction Welcome to a new operating systems post. Today, we are going to clarify some terms frequently used in concurrency and operating systems design. You have probably heard of the following terms... Processes and threads Shared memory and resources Race conditions Mutual exclusion Critical section or critical region Synchronization primitives or constructs Locks and spin

Python for loop else clause

Introduction In this post, we are going to discuss a rarely used Python feature. We are familiar with the regular for and while loops but using an else clause after a loop is not common. We can live without this language feature however it can be used to write elegant code. Let us take an