Skip to content
Advertisement

Can you have variables within triple quotes? If so, how?

This is probably a very simple question for some, but it has me stumped. Can you use variables within python’s triple-quotes?

In the following example, how do use variables in the text:

JavaScript

I would like it to result in:

JavaScript

If not what is the best way to handle large chunks of text where you need a couple variables, and there is a ton of text and special characters?

Advertisement

Answer

One of the ways in Python 2 :

JavaScript

Also look at string formatting

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement