Python: How to use the dictionary get( ) method

Lets say we have a small Python dictionary called fruit that looks like this: fruit = {‘a’:’apple’, ‘b’:’banana’, ‘c’:’cherry’} The most common way to get a value is to retrieve it by its key, using this special syntax: name_of_dictionary[ name_of_key ] By using the name of the key in brackets after the name of the … Continue reading Python: How to use the dictionary get( ) method

Python: How to use List Comprehensions

List Comprehensions were introduced to the Python language in PEP-202 to provide a more concise syntactical way to produce lists where map(), filter(), for loops, and if statements would normally be used. A list comprehension can be summed up like this: new_list = [item action for item in existing_list with optional if condition] This is … Continue reading Python: How to use List Comprehensions

Flask: How to get up and running in less than 5 minutes

The following instructions are for running Flask on Windows with Python 3 (Anaconda). To run Flask, you will first need to install Flask in your Python Scripts folder. To do this, run `pip install flask` in a command window. Then confirm that the installation was successful by loading python and giving it the import flask command. … Continue reading Flask: How to get up and running in less than 5 minutes