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 trialsaif ahmad
6,352 Pointsoperator spacing code challenge
i am not able to make the code more cleaner any help will be appreciated
numbers=[1, 2, 3, 4, 5]
def add(num1 , num2):
return num1 + num2
def subtract(num1 , num2):
return num1 - num2
def mathy(num1 , num2):
up = add(5 + 7, 7 + 9)
down = subtract(6,3)
return add(up,down)
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! The majority of the "spacing errors" in your code have to do with your use of commas between arguments and parameters. Here's an example of what you have typed:
def add(num1 , num2):
But if we want it really clean looking there shouldn't be a space between the first parameter and the comma. So it should look like this:
def add(num1, num2):
Note the removal of the space after num1
.
Here's a place where you didn't put a space at all.
down = subtract(6,3)
That should look like this:
down = subtract(6, 3)
Note the space after the comma and before the 3.
Also, on your first line there should be a space both before and after the equals sign.
I believe you should be able to get the challenge done with these hints, but let us know if you're still stuck. Good luck!
saif ahmad
6,352 Pointsthanks a lot it worked!!!!
saif ahmad
6,352 Pointsthanks a lot it worked!!!!