I'm writing a program where the user inputs something and then the code looks in a text file and reads line by line, if what they entered is in a specific line than the code prints something depending on the line it's in. Here is what I have come up with, however when ran my code seems to produce nothing.
sol1 = "generic solution 1"
sol2 = "generic solution 2"
q = input("bla bla bla\n")
def test():
with open("textfile.txt") as t:
line1 = t.readlines(1)
line2 = t.readlines(2)
for q in t:
if q in line1:
print(sol1)
elif q in line2:
print(sol2)
test()
Could someone tell me what I've done wrong or any areas where I can improve the code. The textfile contains this
screen touchscreen
battery charge