Questions about the specifics of strings

I keep getting “Failed to test your code” for the first section.
I’ve defined the code:

def repeat_stuff(stuff, num_repeats):
print(" ")

but I am not allowed to continue onto the next section. Am I doing something wrong?

I keep getting the same error for “Control flow” lesson 9.

I’ve even copied in the solution code, and it still tell me that “Failed to test your code” and just doesnt wan’t to move on.

Yes, it is. When you concatenate it 10 times, it would make sense.

You also have to make sure the R in Row is capitalized. I just spent an hour trying to figure out why it wasn’t working even though the console showed “row 3” XD…

I got it!!!

def repeat_stuff(stuff, num_repeats):
‘indented here’ print()
repeat_stuff("Row ", 3)

That’s it! I had originally had an ‘=’ sign after the ‘repeat_stuff’ of line 3. Another key factor was to make sure there is a space after the ‘Row’ of the "Row " on line 3. --> ‘Row_3’.
Hope this helps someone.

Thank you!

This exercises is awful…

2 Likes

Make sure to capitalize the R in "Row "…

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

repeat_stuff("Row ",10)

This is not working. Does anyone know why it will not print ‘Row Row Row’

That line can be wrapped in a print statement.

print ( ... )

def repeat_stuff(stuff, number_repeats):
print()

repeat_stuff("Row ", 3)

Remember it is OUTSIDE of the function, so there is no space before repeat_stuff in the line 4.

hmm i think its cause you’re missing the full stop at the end.

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

also don’t miss the space after row .

1 Like

Can’t get past section 3, I don’t know what am I missing, it states:

Change the print statement inside repeat_stuff to a return statement instead.

It should return stuff*num_repeats .

WOW… this is really frustration with code program.
can some please tell what is the diference.
repeat_stuff(stuff = "Row ", num_repeats = 3) vs
repeat_stuff("Row ", 3)

If that is the function call, then the above is invalid since we would not write defaults into the argument, only values. The defaults would be written into the parameter list.

One would advise against using stuff="Row " as a default first parameter. Just use (stuff, num_repeats=3) so the lesson checker doesn’t have more to squawk about.

This was honestly my issue. Wish it was more lenient when it came to capitalization.

Hey guys I actually have a different problem I am stuck on the part 6 the question is as follows 6.

Create a variable called song and assign it the value of repeat_stuff called with the singular input lyrics .
it seems funny because the the function passes two arguments but it’s only calling for one any ways here’s my code thank you.

def repeat_stuff(stuff, num_repeats= 10): 
  return stuff*num_repeats
lyrics = repeat_stuff('Row ', 3) + 'Your Boat.'
song = repeat_stuff(lyrics)

Hi !
I don’t know what’s wrong, because “Row Row Row your Boat.” is printed well but the exercise keeps saying " Expected lyrics to be defined."

I wrote this :

def repeat_stuff(stuff, num_repeats = 10):

lyrics = stuff*num_repeats + "Your Boat."

return lyrics

print(repeat_stuff("Row ", 3))

thanks for your help !

edit : I don’t know how to change this grey stuff in this message