0

Suppose I write a line in python as:

result_string = f"panel_index_numbers={(','.join(str(n) for n in panel_index_numbers).replace(',', ':'))}"

How can I write without errors by separating the datas inside the curly braces in two different lines, i.e. in first line the datas should be : result_string = f"panel_index_numbers={(','.join(str(n) for and in the second line the datas should be n in panel_index_numbers).replace(',', ':'))}". I need to write it in 2 separate lines as in one particular line the bytes should be upto 79 bytes.

Pascal Bugnion
  • 4,878
  • 1
  • 24
  • 29
sriyam
  • 51
  • 1
  • 3
  • can you include the expected output – Alen Paul Varghese Apr 20 '21 at 09:16
  • 2
    Concerning readability this might be one of the places where you should calculate the value in the curly braces before using the f-string. – Matthias Apr 20 '21 at 09:18
  • expected output is status=SUCCESS,panel_index_numbers=1:11...This is fetching data from a config file.i mean to say that the code is working properly..I just want to put the datas inside the curly braces of the f'string in 2 different lines.How can i do that ? – sriyam Apr 20 '21 at 09:19
  • It worked..Yes it worked by following https://stackoverflow.com/questions/45965007/multiline-f-string-in-python – sriyam Apr 20 '21 at 09:22
  • 1
    I just tested it and yes, it works. I didn't expect it to. My apologies to @python_user who found the correct duplicate and who deleted it because I was pretty sure that it didn't apply here. – Matthias Apr 20 '21 at 09:31
  • Yes ,,it answered ..I could use triple quotes and it worked .. – sriyam Apr 20 '21 at 12:31

0 Answers0