2024-05-06 07:44:35 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
filename = sys.argv[1]
|
|
|
|
|
|
|
|
with open(filename, "r") as fileobj:
|
|
|
|
max_linelength = 0
|
|
|
|
longest_line = -1
|
|
|
|
|
2024-05-07 08:17:09 +02:00
|
|
|
for i, line in enumerate(fileobj):
|
2024-05-06 07:44:35 +02:00
|
|
|
if len(line) > max_linelength:
|
|
|
|
max_linelength = len(line)
|
|
|
|
longest_line = i + 1
|
|
|
|
|
|
|
|
print(f"The longest line is line {longest_line} with a length of {max_linelength}.")
|