Advertisement
ZarTek-CREOLE

Untitled

Jan 30th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. def split_msg(msg, max_len=250):
  2.     if len(msg) <= max_len:
  3.         return msg
  4.     words = msg.split()
  5.     result = []
  6.     current_line = ""
  7.     for word in words:
  8.         if len(current_line + word) > max_len:
  9.             result.append(current_line)
  10.             current_line = ""
  11.         current_line += word + " "
  12.     result.append(current_line.strip())
  13.     return "\n".join(result)
  14.  
  15. MSG = "..." # la reponse de openai
  16. # split tout les 250 carctere pour etre en plusieurs lignes :
  17. MSG = split_msg(MSG)
  18. # affichiage de MSG "....................\n.......................\n..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement