How do I get variables between two strings ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GeaneyM

I have been trying to get the following to code to work but it keeps giving me an error,

var story = (“Text”+variable+“Text”)

Can anyone help to resolve this issue?

:bust_in_silhouette: Reply From: kidscancode

If you get an error, it would help to share what that error is.

What kind of data is in variable? If it’s not a string, then + will give an error. You’ll need to convert it to a string: "Text" + str(variable) + "Text".

For more complete string formatting, such as decimal places, etc. see:

:bust_in_silhouette: Reply From: eSKaZed

I think you were looking for:
print("My first string", myVar, "my second string")