I've tried many different things to achieve this, simply I want this:
import requests
path1 = 'D:\test\Files\/results.txt'
lines1 = open(path1).readlines()
ctr = 0
for i in lines1:
try:
r = requests.get(i)
if r.status_code != 200:
ctr += 1
print(i, " Status Code: ", r.status_code)
except requests.ConnectionError:
ctr += 1
print(i, " Failed to connect")
print("Counter", ctr)
to output like this:
URL Status Code: xyz
But instead I'm getting:
URL
Status Code: xyz
So, what's the best way to print out something in the same line with Python?