-4

I have a key text "Outros" and a text file im reading and enumerating. I need to print only the lines that starts with that key. Is it possible?

Im alreadying printing lines, but it prints every line that has this key inside the line, not only the start. I really have no idea of how i can do this.

for index, line in enumerate(lines):
    if a in line:
        print(line.rstrip())
    if b in line:
        print(line.rstrip())
Vitor Vito
  • 35
  • 5

1 Answers1

3
for index, line in enumerate(lines):
    if line.startswith('Outros'):
        print(line)
Tom Lubenow
  • 1,109
  • 7
  • 15