names = []
with open('name_data.txt', 'r') as file:
    for lineno, line in enumerate(file):
        if lineno % 5 == 0:
            if not line.startswith('name'):
                raise ValueError('line did not start with "name".')
name = line.split(':', 1)[1]
name = name.strip()
names.append(name)
print(names)
How do I only print every 5th line