FAQ: Introduction to Functions - Review

#24

Hi,
Can someone explain to me the last part
def repeat_stuff(stuff, num_repeats = 10):
return (stuff*num_repeats)

lyrics = repeat_stuff("Row ",3) + "Your Boat. "

song = repeat_stuff(lyrics)
print(song)

how come song = repeat_stuff(lyrics) repeats lyrics 10 times?
I mean I understand its because of this line of the code:
def repeat_stuff(stuff, num_repeats = 10):

But why it multiplied it 10 times? I mean the sign is = not *

#25

the multiplying happens on the line below:

return (stuff*num_repeats)

num_repeats = 10 only means that the number of repeats will be 10 by default.

1 Like
#26

I dont understand why , song = repeat_stuff(lyrics)
can anyone help? thx

#27

cant get past section 5

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

lyrics = repeat_stuff("Row " , 3) + "Your Boat "

i get Expected lyrics to equal "Row Row Row Your Boat. "

#28

Is the trailing whitespace expected?