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 trialCharles Harpke
33,986 PointsAdd the correct amount of whitespace between the functions, between the functions and the class, and before the class me
ERROR: Your file has 4 error(s) on line(s) 8, 10, 12, 14: blank line contains whitespace; no newline at end of file.
What is the relevance of whitespace?
def first_function(arg1):
return 'arg1 is {}'.format(arg1)
def second_function(arg1):
return 'arg1 is {}'.format(arg1)
class MyClass:
args = [1, 2, 3]
def class_func(self):
return self.args
def first_function(arg1):
return 'arg1 is {}'.format(arg1)
def second_function(arg1):
return 'arg1 is {}'.format(arg1)
class MyClass:
args = [1, 2, 3]
def class_func(self):
return self.args
9 Answers
Kenneth Love
Treehouse Guest TeacherYou shouldn't have whitespace (spaces, tabs, etc) on blank lines. They should be nothing but the newline control character. Since Python uses whitespace to determine scope/namespacing, having whitespace on blank lines can confuse the interpreter.
Charles Harpke
33,986 PointsThank you.....took me a few seconds to wrap my head around that. :)
Mahdi Jafari
17,887 Pointsthe below code works if you get this "no newline at end of file." just click on the enter button and add one new line at the end of the code.
def first_function(arg1):
return 'arg1 is {}'.format(arg1)
def second_function(arg1):
return 'arg1 is {}'.format(arg1)
class MyClass:
args = [1, 2, 3]
def class_func(self):
return self.args
Lynn Collins
10,080 PointsWhy am I so slow at these damned challenges!
MUZ140239 Tinashe Banguwangu
2,825 PointsBummer! Your file has 2 error(s) on line(s) 11, 14: blank line contains whitespace; trailing whitespace.: on the same challenge am facing this problem am falling to understand what it is?
Kenneth Love
Treehouse Guest TeacherBlank lines should be completely blank, this means no tabs or spaces on them. And you shouldn't have extra spaces/tabs on the end of lines.
D Elis
13,571 PointsThis code passed but doesn't show up correct when I paste it. Instructions:
**be careful to erase all white space from any new lines**
After the first function 2 blank lines After the second function 2 blank lines One blank line after MyClass One blank line after args One blank line after the return statement of class_func(self)
Properly indent all returns by just pressing enter after each function.
Indent args & the function class_func(self) by pressing tab once
def first_function(arg1): return 'arg1 is {}'.format(arg1)
def second_function(arg1): return 'arg1 is {}'.format(arg1)
class MyClass:
args = [1, 2, 3]
def class_func(self): return self.args
Manish Kumar Meena
Python Development Techdegree Student 2,594 Pointsdef first_function(arg1): return 'arg1 is {}'.format(arg1)
def second_function(arg1): return 'arg1 is {}'.format(arg1)
class MyClass:
args = [1, 2, 3]
def class_func(self):
return self.args
Lynn Collins
10,080 PointsI'm much too slow at this!!!! def first_function(arg1): return 'arg1 is {}'.format(arg1)
def second_function(arg1): return 'arg1 is {}'.format(arg1)
class MyClass: args = [1, 2, 3]
def class_func(self): return self.args
Luke Shephard Zikuyumo
1,655 Pointsdef first_function(args1): return 'args1 is {}'.format(args)
def second_function(args1): return 'args is{}'.format(args1) class MyClass:
args =[1, 2, 3]
def class_func(self):
return self.args
Still I get bummer what's wrong with this code.
Steven Smith
5,660 PointsThis was the toughest one yet. Make sure to delete the tab in your new line at the end.
Tomer Inbar
2,248 PointsTomer Inbar
2,248 PointsI am getting "Bummer! Your file has 1 error(s) on line(s) 13: no newline at end of file."
but I don't have any(at least none that I could find). I made sure that the s of .args is the last char, nothing more to delete. any ideas? Kenneth Love