How to display a variable inside quotes

https://www.codecademy.com/courses/learn-python-3/lessons/learn-python-syntax/exercises/review?action=resume_content_item

my_age = 18
greeting = "Well hello there, "
name = "Tim"
greeting_with_name = greeting + name + ", I am (my_age) years old."
print(greeting_with_name)

I’m trying to print "Well hello there, Tim, I am 18 years old, but I have no idea how to code my_age inside the quotation marks.

Ofcourse I can make the code look like this

greeting_with_name = greeting + name + "I am " + my_age + " years old."

But there’s no fun in that

Actually, that’s exactly what you need to do, at some level you will have to write the leading text, then the string representation of your data, then the rest of the text.

But since that’s a common thing to do, to abstract that process away a bit, you’d instead put placeholders in your string, and supply the values separately.

Or even, put special delimiters in the text that says “run this and use the result” (though, if you think about it, that’s not really any different from using + between strings, just a bit more streamlined.

print(f'{1+1}')
print('{}'.format(1+1))
1 Like

Wow thanks for the answer, I will be straight out with you. I lost you after the first sentance. But don’t worry, I’m gonna learn how to code, I’m feeling like mf Naruto over here.

Hi @web5654903635,

See official documentation here:

There is a lot of information there. You can practice by copying and modifying some of the examples to produce desired results.

Also later there is the option to make place holders in the string and later to insert the variables.
But follow python tutorials and you will learn about that later