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 trial

Python Functions, Packing, and Unpacking Introduction to Functions Create and Call a Function

how 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".?

creating_functions.py
my_first_function    ['pass'] 

4 Answers

Josh Keenan
Josh Keenan
20,315 Points

I 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
PLUS
Emily Senechal
Courses Plus Student 1,384 Points

That is what I entered for my answer and I keep getting this error message

Bummer: Whoops - did you create a function called print_topic?

I'm getting the same error. Did you manage in the end?

duncan Akello
duncan Akello
1,221 Points

def my_first_function (): print ('pass')