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 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'] 

3 Answers

Josh Keenan
Josh Keenan
19,429 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,379 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?