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

String vs String Literals: what is the difference between a string and string literal? thanks

String vs String Literal: what is the difference and why?

2 Answers

Steven Parker
Steven Parker
242,296 Points

The term "string" is more generic and doesn't identify how it is being represented. For example:

name = "James"

This line has two strings, a string variable named "name", and a string literal providing the value being assigned to it.

You will sometimes hear a literal referred to as a "hard-coded value".

thank you . got it.

thank you. got it.