I want to search a file for all lines containing a given string without matching case. How can I make this code case-insensitive?
with open(logfile) as fin: for line in fin: if var.lower() in line.lower(): # makes this case insensitive print 'found', line.rstrip() # You will be printing double new lines # without rstrip here