Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am working on the reportlab. I want to add the variable inside the paragraph.

My variable is 'a'

a = 'Apple'

p = Paragraph("""This is <var> a <\var>"""style=None) 

My expected output is This is the Apple but this doesn't work.

1 Answer

0 votes
by (36.8k points)

If you are using the Python 3.6 and above, you could try the f-strings:

p = Paragraph(f"""This is {a}""", style=None)

Do you wish to learn Data Science from scratch? Enroll in this Data Science Courses

Browse Categories

...