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 trialTracey Bota
317 Pointshow to Create a function Inside the function body, indent 4 spaces and write words .
Howdo iCreate a function called my_first_function. Inside the function body, indent 4 spaces and write the word "pass".?
my_first_function ['pass']
4 Answers
Josh Keenan
20,315 PointsI am going to recommend that you watch the previous videos again, functions area big part of programming and it seems you haven't got your head around it yet.
def my_first_function():
pass
The def
tells python that the next thing to come will be the name of a function, def
means define, so you are defining your function my_first_function
. Each function needs the ()
at the end of its definition too, some functions can be given things, like a string, and then do stuff to the string or with it.
In a lot of languages to see what is in a function you have {}
and put all the code for the function inside them. In python we end the definition line with :
and then after that we just indent all the code, this lets the interpreter know where the function is and at what point it stops. Hope this helps
Emily Senechal
Courses Plus Student 1,384 PointsThat is what I entered for my answer and I keep getting this error message
Bummer: Whoops - did you create a function called print_topic
?
Titose Chembezi
3,361 PointsI'm getting the same error. Did you manage in the end?
duncan Akello
1,221 Pointsdef my_first_function (): print ('pass')