Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python for Beginners Create a variable

Jessica Brown
Jessica Brown
228 Points

Challenge task 1 of 1- Create a variable

I have tried everything I can think of to write this code right, and I am obviously doing something wrong. How do I make a variable named name, and then assign the variable to my own name?

variable.py
name = Jessica
print("Jessica")

2 Answers

James Auger
James Auger
565 Points

This is because you're printing off a variable that hasn't been set, nothing has been set to the variable named Jessica. If you want to display "Jessica", pass the variable you have set. This variable is called name, Jessica is data not a variable. Full example: name = "Jessica" print(name)

Jessica Brown
Jessica Brown
228 Points

Thank you so much. I totally get it now :)

James Auger
James Auger
565 Points

You can assign a variable as a string by using quotation marks between Jessica, for example: name = "Jessica" then you can print it off as a string by typing in the variable in the print function with no quotation marks

print(name)

Jessica Brown
Jessica Brown
228 Points

Thank you for responding to my question. I have tried that too and for some reason it won't take it. This is what I have:
name = "Jessica" print(Jessica)

It still says it can't find my variable :(