I have a list of strings that read from file. Each element is a line of file. I want to have an array of this string that have same length. I want to find the longest string and reformat other strings as long as longest string (with space at the end of them). Now I find the longest one. but I don't know how can I reformat other strings. Can anybody help me please?
with open('cars') as f:
lines = f.readlines()
lines = [line.rstrip('\n') for line in open('cars')]
max_in=len(lines[0])
for l in lines:
print (str(len(l))+" "+str(max_in))
if max_in < len(l):
max_in=len(l)
print max_in