To convert a multiline string to a single line:
my_str = """\
First line
Second line
Third line
"""
result = " ".join(line.strip() for line in my_str.splitlines())
print(repr(result)) # 👉️ "First line Second line Third line"
المصدر
https://bobbyhadz.com/blog/python-convert-multiline-string-to-single-line
العودة إلي لغة البرمجة البايثون Python