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 trialvipul khairnar
66 Pointsi wrote the codes but is says invalid syntax
i wrote the codes but is says invalid syntax
def answer_the_phone(): greeting = "Hello, treehouse?" print(greeting)
2 Answers
Alexander Davison
65,469 PointsDid you remember to indent (add four spaces to the beginning) of the code that is part of the function?
Python will cause an error if you don't indent, because Python won't know that part of your code is part of the function.
To fix this, add 4 spaces to the beginning of the lines that are part of the answer_the_phone
function, like this:
def answer_the_phone():
greeting = "Hi Treehouse"
print(greeting)
Good luck! ~alex
__ROLLER__ Angel
25,606 Pointsdef answer_the_phone():
greeting = "Hi Treehouse!"
print(greeting)
Pay extra attention to the indentation as it is a huge part of Python syntax. Be sure to check out this style guide
__ROLLER__ Angel
25,606 Points__ROLLER__ Angel
25,606 PointsPay extra attention to the indentation as it is a huge part of Python syntax. Be sure to check out this style guide