FAQ: Introduction to Functions - Review

The above screen shows only too clearly what your mistake is. There is a missing : (colon). May I suggest resetting the lesson and follow through the steps (if for only entertainment) with this syntax error corrected.

This explanation has been the most helpful to my misunderstanding. However, what I would like to know now is how we are overwriting the default argument num_repeats of 10 in line 1. I would have assumed that if the argument num_repeats was made default to 10 that I would get an error when assigning the argument num_repeats an int of 3 later on. I hope this makes sense. Thank you.

The default parameter is only used if no argument is passed to the function in its place, e.g.

def example(x=3):
    return x
print(example())  # Without an argument, output is: 3
print(example(5))  # Out: 5
print(example())  # Falling back to the default again. Out: 3

Ok yes, Thank you that makes sense to me now. I appreciate your time.

1 Like

At step 3 and not sure what I am doing wrong


def repeat_stuff(stuff, num_repeats):
  return stuff*num_repeats

repeat_stuff("Row ", 3)

Could you provide details of the error? Is there a specific message outputted to say what the problem is?

It’s also worth having a little look at the following post on how to format code since indentation is so important in Python-