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 (Retired) Ins & Outs Ins & Outs

Antonio Velardo
PLUS
Antonio Velardo
Courses Plus Student 111 Points

create a variable names Tree and house? name = "Antonio" 3 = "Tree" 4 = House print 3 and 4

it gives me a bummer syntax Error

name.py
name = "Antonio"
3 = "Tree"
4 = House
print 3 and 4 

Could you please include the syntax error?

3 Answers

Hello Antonio,

I am not familiar with python but looking at this I suspect there are a few issues:

  • You cannot use numbers as variable names (e.g. 3 and 4)

  • House is not surrounded by quotes

  • The syntax you are using to print is incorrect. Any strings need to be surrounded with " ". If you want the output of a variable to be added to a larger string, you will need to add +.

name = "Antonio"
plant = "Tree"
shelter = "house"

print plant + shelter + " loves " + name + "."
# "Treehouse loves Antonio."

Cheers,

Jacob

Isaac Calvo
Isaac Calvo
8,882 Points
name = 'my name'
treehouse = "Tree" + "house"
email_greeting = treehouse + " " + "loves" + " " + name

cant use numbers at the beginning of a variable name in python. 1 = 'one' will fail but one1 = 'one' works. Also anytime you use a string it has to be surrounded by quotes.

Antonio Velardo
PLUS
Antonio Velardo
Courses Plus Student 111 Points

thanks isaac

i dont understand the need to splitting "treehouse" in 2 string, what the exercise was trying to suggest? i am referring to the python lesson on string , and the quiz i would i execute the two string?print "tree" + house ?

The reason "treehouse" has been split into two words is to show how variables can be concatenated together.