Solution 1

def max_lines(*file_names):
    max_name = ""
    max_lines = 0
    for file_name in file_names:
        with open(file_name) as fp:
            read_data = fp.readlines()
            if len(read_data) >= max_lines:
                max_lines = len(read_data)
                max_name = file_name
    return max_name

Get Filename with Max Lines

Write a function that receives one or many file paths as parameters and returns
the name of the file with max amount of lines.

Example:

max_lines('file1.txt', 'file2.txt')  # 'file1.txt
max_lines('file1.txt')  # 'file1.txt
max_lines('file1.txt', 'file2.txt', 'file3.txt)  # 'file3.txt

Test Cases

test one file - Run Test

import tempfile

def test_one_file():
    fp = tempfile.NamedTemporaryFile(mode="w")
    fp.write('this is line 1\n')
    fp.write('this is line 2\n')
    fp.write('this is line 3\n')
    fp.flush()

    assert max_lines(fp.name) == fp.name

    fp.close()

test two files - Run Test

import tempfile

def test_two_files():
    fp1 = tempfile.NamedTemporaryFile(mode="w")
    fp1.write('this is line 1\n')
    fp1.write('this is line 2\n')
    fp1.write('this is line 3\n')
    fp1.flush()
    fp2 = tempfile.NamedTemporaryFile(mode="w")
    fp2.write('this is line 1\n')
    fp2.write('this is line 2\n')
    fp2.write('this is line 3\n')
    fp2.write('this is line 4\n')
    fp2.flush()

    assert max_lines(fp1.name, fp2.name) == fp2.name

    fp1.close()
    fp2.close()
def max_lines(*file_names): pass