Advertisement
robjones90

Text creator

Jun 2nd, 2022
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. text = """The Marvel Cinematic Universe (MCU) is an American media franchise and shared universe that is centered on a
  2. series of superhero films, independently produced by Marvel Studios and based on characters that appear in
  3. American comic books published by Marvel Comics. The franchise has expanded to include comic books, short films,
  4. television series, and digital series. The shared universe, much like the original Marvel Universe in comic books,
  5. was established by crossing over common plot elements, settings, cast, and characters. Phil Coulson, portrayed by Clark
  6. Gregg, is on original character to the MCU and the only character to appear across all the different media of the MCU"""
  7.  
  8.  
  9. def side_box(string):
  10.     string = ''.join(('|',string,'|'))
  11.     return string
  12.  
  13. def wrap(_string, length):
  14.     return textwrap.wrap(_string, length)
  15.  
  16. def sub_line_creator(text):
  17.     words = text.split()
  18.     subs = []
  19.     n = 12
  20.     for i in range(0, len(words), n):
  21.         subs.append(" ".join(words[i:i+n]))
  22.     return subs[:12]
  23.  
  24. text_lines = sub_line_creator(text)
  25. print(text_lines)
  26.  
  27. def white_space_creator(text_lines):
  28.     output = []
  29.     for item in text_lines:
  30.         amount_of_characters = len(item)
  31.         output.append(item.center(100, " "))
  32.     return output
  33.  
  34.  
  35. counter = 0
  36. for x in white_space_creator(text_lines):
  37.     if counter == 0:
  38.         counter += 1
  39.         print(f"{'|----------------------------------------------------------------------------------------------------|':^200}")
  40.     else:
  41.         counter +=1
  42.         text = side_box(x)
  43.         print(f"{text:^200}")
  44.         if counter == len(text_lines):
  45.             print(f"{'|----------------------------------------------------------------------------------------------------|':^200}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement