Mega Code Archive
Categories
/
Python Tutorial
/
File
Use the max() built-in function to get the longest string length
f = open('/etc/motd', 'r') allLineLens = [len(x.strip()) for x in f] f.close() print max(allLineLens)