Код: Выделить всё
file_name = input()
first_word = input()
second_word = input()
file = open(file_name, mode ='r')
file_lines = file.readlines()
file.close()
first_word = first_word + '\n'
second_word = second_word + '\n'
first_word_index = 0
second_word_index = 0
if first_word in file_lines:
first_word_index = file_lines.index(first_word)
if second_word in file_lines:
second_word_index = file_lines.index(second_word)
if first_word_index and second_word_index:
print(file_lines[first_word_index:second_word_index + 1]
elif not first_word_index and second_word_index:
print(file_lines[:second_word_index]
elif first_word_index and not second_word_index:
print(file_lines[first_word_index:]
Код: Выделить всё
File "/home/runner/local/submission/main.py", line 22
elif not first_word_index and second_word_index:
^^^^
SyntaxError: invalid syntax
Подробнее здесь: https://stackoverflow.com/questions/791 ... per-syntax