I'm writing a program that converts a blocklist into a BIND9 zones file for a blackhole/sinkhole DNS server. Within the script I have code similar to the following:
Any help would be greatly appreciated.
# The following list is just for the sake of illustration, the actual list comes from reading the blocklist file my_list = ["foo.com/index.html", "bar.com/downloads/malware.exe", "conteso.com/phishing/email.htm", "domain.com/blog/test", "[Adblock]", "another.domain.com/another/test/blog", "blah.net/blah/blah/blah"] for i in my_list: if(i != "[Adblock]"): print("This block should only execute if i is NOT equal to [Adblock].")The issue is that the if block ALWAYS executes, whether i is equal to [Adblock] or not. I've tried escaping the brackets ("\[Adblock\]") but that didn't help either. I also tried single quotes and single quotes while escaping the brackets.
Any help would be greatly appreciated.