Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Write Better Python Cleaner Code Operator Spacing

León Pozo
León Pozo
2,276 Points

Stuck at Operator Spacing Challenge.

I am currently at the Operator Spacing code challenge of the Write Better Python course. I think I solved it correctly, but when I check my work I get the message "Bummer: Your file has 1 error(s) on line(s) 15: no newline at end of file." I tried to add an empty line at the end of the file but got the message "Bummer: try again!".

Can anyone tell me if there what is wrong or if there is an error I didn't notice?

numbers = [1, 2, 3, 4, 5]

def add(num1, num2):
    return num1 + num2

def subtract(num1, num2):
    return num - num2

def mathy(num1, num2):
    up = add(5+7, 7+9)
    down = subtract(6, 3)
    return add(up, down)

1 Answer

Mel Rumsey
.a{fill-rule:evenodd;}techdegree seal-36
Mel Rumsey
Treehouse Staff

Hey there León Pozo !

There are a few things here:

  • Check the spacing in the add function call in the mathy function. You always want spaces between numbers and operators.
  • Doublecheck your subtract method. The value being returned is not using a correct parameter. python def subtract(num1, num2): return num - num2 `
  • Lastly, at the end of a file, there needs to be a blank line according to PEP8 standards.

Hope this helps!

León Pozo
León Pozo
2,276 Points

This worked, thanks!