Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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?

starter.py
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

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!