0
How can I get a line in a file for a key word in the next line?
for example: if "bike" is in the line, print the previous line
1 Odpowiedź
+ 2
u can use this lines = [line.rstrip('\n') for line in open("filename.txt")] to put the lines into a list then u can access each line with the list index - print(lines[0]) will print the first line of the text and same with the other lines just change the index number