0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning — completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Elvis Barbee
PRO
last year
Elviscountry asked

Why don’t you have to put the variable in curly braces?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

So, in Python, you don't need to use curly braces {} when printing a variable like this:

name = input("Enter your name: ")
print("Your name is", name)
    

That works because print() can take multiple things, separated by commas. It just puts spaces between them automatically, so you don't have to do anything fancy.

Now, curly braces do show up when you're using something like an f-string. That looks like this:

print(f"Your name is {name}")
    

In that case, the {name} is inside the string, and Python replaces it with the actual value of the name variable — but only because the string starts with an f.

So yeah, curly braces are just for special formatting stuff like f-strings. If you're just printing normally with commas, you don’t need them at all.

Python
This question was asked as part of the Learn Python Basics course.