Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def find_longest(list_of_words):
  2.     return len(max(list_of_words, key=len))
  3.  
  4. def flush_right(list_of_words, file_name):
  5.     n = find_longest(list_of_words) +3
  6.    
  7.     with open(file_name,'w') as file:  
  8.       for word in list_of_words:
  9.         file.write(word[::-1].rjust(n) + '\n')
  10.  
  11.  
  12. def main():
  13.     list_of_words = ["Ala", "ma", "kota"]
  14.     name_of_file = 'test.txt'
  15.     flush_right(list_of_words, name_of_file)
  16.  
  17. if __name__ == "__main__":
  18.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement