I wrote a program in Python 2.7. It's working great in the IDLE Shell, but when I try to open it in the Python Command Line, it open and closes immediately. Like, in a split second.
Please help.
import socket
import time
TARGET_PROMPT = "What website do you want to find the IP address of?\n\n"
def ping():
target = raw_input(TARGET_PROMPT)
start = time.time()
print("\nTrying to connect...")
try:
ip_address = socket.gethostbyname(target)
end = time.time()
connection_time = end - start
print("Connection established.")
print("IP address found: " + ip_address + "\n")
except Exception as e:
print("Connection failed.\n")
while True:
ping()
Edit: I deleted and reinstalled Python, and now it seems to be working fine.