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".?
my_first_function    ['pass'] 

3 Answers

Josh Keenan
Josh Keenan
19,401 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():

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
Emily Senechal
Courses Plus Student 1,378 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?