Learning Python: Introduction to Functions 11. (Review)


#1

I don’t understand what I am doing wrong. I made the function but can’t figure out how to turn the function into the lyric. I’ve been working on this lesson for over an hour, typing, deleting, retyping.

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

def repeat_stuff(stuff = "Row ", num_repeats = 10):
  print(stuff * num_repeats)
  return(stuff * num_repeats)
lyrics = repeat_stuff("Row ", 3)+ str("Your Boat")


#2

When you post, use the </> button and copy your code here in the forum. This will show us your code with formatting.


#3

There are two issues:

One issue is your calling of

repeat_stuff("Row " * 3)  #nope
repeat_stuff("Row", 3)  #yes passing "Row" in and 3 (telling it to repeat 3 times) 

The other issue is with your repeat_stuff() calling in your lyrics variable.

repeat_stuff is a function. If you want to save what it does, then you will need to assign a variable to it to save what it returns to you.

You can do one of the following to help make the code work.

  1. assign a variable to repeat_stuff(“Row” , 3) then call that variable instead of repeat_stuff in lyrics
  2. or directly call the function in lyrics: lyrics = repeat_stuff(“Row” , 3) + string