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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Ryan Butts](https://secure.gravatar.com/avatar/1694fe0814f8536eab9424bfd90f0433?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ryan Butts
1,479 PointsWhat does craig mean when he says "string literals" or "boolean literals"? What does "literals" mean?
Just a bit confused by the term literals and how it relates to strings, booleans, and I guess the other data types as well? Thanks!
1 Answer
![Jennifer Nordell](https://uploads.teamtreehouse.com/production/profile-photos/5432702/micro_jen-square.jpg)
Jennifer Nordell
Treehouse TeacherHi there, Ryan Butts! A "literal" in computer science is a fixed value. For instance, the string "hello world"
is a string literal. The "opposite" of a literal (if you want to think of it that way), is a variable.
Take this example:
my_string = "Hello World"
my_bool = True
print("Hi, Ryan") # print a string literal
print(my_string) # print a variable
print(my_bool) # print a variable
print(False) # print a boolean literal
The variable my_string
holds a string literal of "Hello World". And the variable my_bool
holds the boolean literal True
. Because variables are just that, they don't really have a type until they are defined. Thus, if I were to say I'm printing a boolean literal, I would mean that I'm either printing True
or False
as opposed to a variable that holds that value.
Hope this helps!
boi
14,242 Pointsboi
14,242 PointsNicely explained. 👍
Ryan Caalim
261 PointsRyan Caalim
261 PointsThank You for explaining, Jennifer!