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 trialAntonio Velardo
Courses Plus Student 111 Pointscreate a variable names Tree and house? name = "Antonio" 3 = "Tree" 4 = House print 3 and 4
it gives me a bummer syntax Error
name = "Antonio"
3 = "Tree"
4 = House
print 3 and 4
3 Answers
Jacob Moyle
6,150 PointsHello 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 quotesThe 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
8,882 Pointsname = '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
Courses Plus Student 111 Pointsthanks 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 ?
Jacob Moyle
6,150 PointsThe reason "treehouse" has been split into two words is to show how variables can be concatenated together.
Jacob Moyle
6,150 PointsJacob Moyle
6,150 PointsCould you please include the syntax error?