Yeah, that works fine! But if you’re after something more flexible, I’d recommend using islice()
from the itertools
module. It gives you more control over how many lines you want to skip. Here’s how:
from itertools import islice
myFile = open("football.txt", "r")
lines = list(islice(myFile, 2, None)) # Skip the first two lines
# rest of the code
It’s nice because it allows you to skip any number of lines, or even continue reading the rest of the file. It’s kind of a neat trick when you need a bit more control over how to skip a line in Python!