use the max() built-in function to get the longest string length : Loop through : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Loop through »

 

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)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo File
» Loop through