Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def width_aligment(string):
- before(string)
- maxlen = len(max(string, key = lambda x: len(x)))
- for i in range(len(string)):
- splits = string[i].split()
- if len(splits) != 0:
- last_word = splits[len(splits) - 1]
- splits = splits[:-1]
- strips_div = (maxlen - len(string[i])) // (len(splits) )
- strips_mod = (maxlen - len(string[i])) - strips_div * (len(splits))
- for j in range(len(splits)):
- splits[j] = splits[j] + " "*strips_div
- if strips_mod > 0:
- splits[j] = splits[j] + " "
- strips_mod -= 1
- splits.append(last_word)
- string[i] = " ".join(splits)
- print(string[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement