Confused about scope and positional argument

https://www.codecademy.com/paths/computer-science/tracks/cspath-intro/modules/cspath-python-functions/lessons/intro-to-functions/exercises/review

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

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

I’m wondering why the value 3 doesn’t get reused in the second function of repeat_stuff. Could somebody give me a thorough explanation of what is going on in this script?

Thanks,
MP

why would we want this?

if we don’t provide any argument, the default value (10) is used. If we want our song to consist of 10 lines (which seems to be the task at hand), we don’t need to provide any argument, that is the advantage of a parameter with a default value

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.