Motive
I don't even know what to write in the motive section, but as I usually write something in the motive section. This would help you find your IP address.
The Project
First import socket, and by the way it's pre-installed so, no pip install needed. The create a variable called hostname then we will get the hostname with sockets.gethostname(). Then create another variable called ipAddress then get our IP address with that hostname, socket.gethostbyname(hostname). Then just print ipAddress by print(ipAddress). That's it!
The Full Code
If you have any doubts or errors in the program feel free to comment down below and I will respond as early as possible. And if I have made any mistake please feel free to correct me in the comment box below. Don't forget to follow us for such python related content.
Comments
Post a Comment