How to get the IP address in Python
Python exposes a socket
library that allows us to perform networking tasks such as getting the IP Address as well as getting the Hostname of our system.
The above code imports the socket library and then runs a safe block of code.
We need to first get the hostname and then use that to get the IP Address.