Questions about the specifics of strings

Python’s PEP 8 style guide states that there should be no whitespace between the function name and the opening bracket.

Welcome to the forums!

1 Like

Thank you for clarifying! Will there be a version in the future where the compiler would be unable to read a space? I prefer it stylistically as it looks cleaner to me and is more familiar from how English is written.

It seems unlikely to me at least that they’d ever remove the option for spaces. I think it’s more likely though that any large project you may work on in the future may already have their own style requirements and maintaining consistency is important. It would be bad practice to try and make your code style different to that of your collaborators and may not be accepted. So whilst you could run code with spaces as you please but it might be a style you have to unlearn down the line, personally I’d recommend sticking with the convention unless there’s a very compelling reason not to.


ok got, (didnt see the answer here) it its case sensitive so "Row " (not "row ")

14 posts were split to a new topic: Help with string functions review

Hey, there, I’m stuck at part two, here’s my code:

As far as I can tell there is no space in front of repeat_stuff in Line 3, seperating, it from the function, and the space in "Row ", as suggested by the error message is in place. Does anyone know what prevents my code from passing the requirements?

I’m not sure of the exact test being performed but I’m wondering if there is a test for text matching a specific line. In this case you might want to bring your code into line with the standard style guidance-

In this specific case, I’d assume it’s the line repeat_stuff ("Row ", 3) that is causing issues. Remove the gap between the function name and the parentheses and it should then pass. Other alterations which may or may not be necessary include removing the spaces in the function definition def myfunc(mypar): would be the standard.

Removing the gap in Line 3 did, thanks for the advice. I wasn’t aware that there is a ‘correct’ way for spacing, but I suppose that’s part of the learning process

Python’s style guide recommends against the use of a space between the name of a function and the opening parentheses in a function call.

Your code would still run even with the space, but Codecademy is likely checking for exactly repeat_stuff("Row ", 3) rather than the output.

Currently stuck on Step 3:

Change the print statement inside repeat_stuff to a return statement instead.
It should return stuff*num_repeats .

not sure what they’re specifically trying to ask but i’ve tried everything I could think of to get past it but I’ve hit a wall.

Welcome to the forums!

Before Step 3, you should have used print statements to print out something like "Row Row Row ". Now, the exercise is asking you to return this instead.

While the print method prints out a message to the console, the return method is used to pass return value(s) back to the function call. This is useful if we want to obtain a value from a function and use it elsewhere in our code.


print("bar") # prints bar

def foo():
  return "bar"

foo() # example of a call to the function, prints nothing

my_var = foo() # stores the returned value from the call to foo()
print(my_var) # prints bar

If I am not wrong in understanding your query, basically you expected
"Row Row Row Your Boat. " as output. But you have not used any print statement. If you use print(lyrics) , you will get the expected one.