Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Joshua Carroll
Joshua Carroll
137 Points

Why does writing print(first_name) not require "", where as everything else in parenthesis does?

Trying to notice consistency, and I found this seems irregular, Wondering the reason. Everything i've put into script so far seems to require quotes, but the first_name variable doesnt. Thank you

1 Answer

Steven Tagawa
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Steven Tagawa
Python Development Techdegree Graduate 14,438 Points

If you print something inside quotation marks, you are printing a literal string. What it will print will be exactly what is inside the quotation marks, every time. If you print something without quotation marks, your are printing a variable. What prints will not be the name of the variable; it will be whatever value has been assigned to that variable.

So if I wrote:

first_name = "Joshua"
print("first_name")
print(first_name)

I would get:

first_name
Joshua

The first print outputs the exact characters that are inside the quotation marks. The second print looks up what has been assigned to the variable called first_name and outputs that.