使用re正则表达式来做
import re
while True:
try:
n = input()
ss = []
for i in range(eval(n)):
ss.append(input())
reg = input()
for i in range(len(ss)):
if re.search(reg, ss[i], flags=re.IGNORECASE) != None:
print(str(i+1) + ' ' + ss[i])
except:
break