Mega Code Archive

 
Categories / Python Tutorial / File
 

Get the longest line

f = open('/etc/motd', 'r') longest = 0 allLines = f.readlines() f.close() for line in allLines:     linelen = len(line.strip())     if linelen > longest:         longest = linelen print longest