# FAQ: Introduction to Functions - Review

#1

This community-built FAQ covers the “Review” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

1 Like
#2

Hi there, quick question!

I understand that with the ‘lyrics’ variable we over-road the number 10 in the function and therefore “Row” appeared 3 times. I’m just wondering what part of the code told “print” to display the whole function 10 times?

7 Likes
#3

This
lyrics = repeat_stuff("Row ", 3) + "Your Boat. "
runs the function giving two arguments, therefore overwriting the 10.

The second step
song = repeat_stuff(lyrics)
runs the function again but this time you’re not overwriting the default num_repeats argument of 10 since you’re not giving a second argument.

6 Likes
#4

I think that when we put (“row”, 3) it defines num_repeats as 3, but when we put just (lyrics) with out any specified number, it used the defined default of 10 applied in step four. I think.

5 Likes
#5

Hi guys,

I’m currently stuck at sub exercise 2. which states

Outside of the function, call `repeat_stuff` .

You can use the value `"Row "` for `stuff` and `3` for `num_repeats` .

what does that translate into python ?

I can’t seem to get it to greenlight it to move to step 3.

15 Likes
#7

Make sure you put the space behind “Row” so that it is "Row ".

14 Likes
#8

Make sure your code is not indented two spaces for this line:

repeat_stuff("Row ", 3)

2 Likes
#9

Hey, thanks for the help!

2 Likes
#10

Why is it that when you define the variable lyrics without the 10 being default it won’t run even though in lyrics we defined both positional arguments?

1 Like
#11

`num_repeats` will be 10 if we do not supply a second positional argument.

``````lyrics = repeat_stuff("Row ") + "Your Boat\n"
``````
``````Row Row Row Row Row Row Row Row Row Row Your Boat
``````

If we supply no arguments it will raise an exception.

`TypeError: repeat_stuff() missing 1 required positional argument: 'stuff'`

If we supply a number in the first position, it will also raise an exception:

TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’

Note that we are building `lyrics` before passing it to create `song`.

``````Row Row Row your boat
``````

is the lyrics,

``````Row Row Row Your Boat
``````

is the song, as in,

``song = repeat_stuff(lyrics)``
2 Likes
#12

You’re right. To reiterate this,

First when the function repeat_stuff is called, the num_repeats is overwritten by 3 specified in the argument. So it print Row Row Row your boat.

Now the next line is executed song=repeat_stuff(lyrics). Note that argument is only one. That argument is assigned to stuff. Argument now holds this value “Row Row Row your boat.” and since the num_repeats is 10. It prints the whole string 10 times.

1 Like
#13

I’m having a hard time figuring out I am doing wrong here.

Number 5

1 Like
#14

Great question! This thread helped me too because I thought the same thing! Got it now!!

1 Like
#17

Could please explain this again. I am unable to understand why the code will show error if num_repeats = 10 is not mentioned. Thank you.

1 Like
#18

Because you are only using:

``````song = repeat_stuff(lyrics)
``````

But the function repeat_stuff needs two parameters to run:

``````def repeat_stuff(stuff, num_repeats=10):
``````

So, when you are using:

``````song = repeat_stuff(lyrics)
``````

and num_repeats = 10 is not mentioned.

The num_repeats is missing and that value is needed.

1 Like
#19

the idea is that if the second argument is missing, the parameter uses the default value. 10 in this case

@aayushishah525, can you post the code with the error so we can better understand what you are talking about?

2 Likes
#20

Capitalize B in boat?

#21

I had the same problem, I tried all the code combinations possible, but it didn’t allow me to continue the exercise…

#22

def repeat_stuff(str(stuff), num_repeats):
print(’’)

repeat_stuff(“Row”, 3)

What am I missing? it won’t green light it
I’ve tried using str() in multiple ways to no effect
The solution only gives me the completed exercise, but all I want help with is this task
I’ve tried the space thing, but no effect
``````print('')