#Inquire f=open("C:\\aaaaaaaaaaaaa\\haproxy.txt", "r", encoding="utf-8") haproxy_list = f.readlines() website_address = input("Please enter the URL to query: ") website_address = "backend " + website_address lenth=len(haproxy_list) #print(website_address) i=0 j=1 for line in haproxy_list: if website_address in line and line.startswith("backend"): print(haproxy_list[i]) j=i+1 while "backend" not in haproxy_list[j] : print(haproxy_list[j]) j+=1 if j >= lenth: break elif j == lenth and i == lenth: print("The content you entered cannot be searched") i+=1 if i == lenth and j==1: print("The content you entered cannot be searched") f.close()