I have a text file called sample_ips.txt containing some random IP addresses as follows:-
182.0.0.15
182.0.0.16
182.0.0.17
I am giving an IP ad
input_ip = raw_input("Enter IP:") # In python 2.x. If you use input() then type your inputs as string (>>Enter IP:"182.0.0.15")
#input_ip = input("Enter IP:") for python 3.x
with open("ip.txt", "r") as ip:
data = ip.readlines()
for ips in data:
ips = ips.strip("\n")
if input_ip in ips:
print ("true")
else:
print ("false")