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 trialRafael Pastrana
Courses Plus Student 268 PointsEOFError
Hi, I'm doing a the Challenge Task 1 of Putting the "Fun" Back in "Function".
I made a working script in the shell but when I check the work in treehouse interface I get an EOFError.
Any thoughts on why this is happening?
Rafael
5 Answers
Kenneth Love
Treehouse Guest TeacherHmm, tested it again today and I get the same error.
Maybe it has something to do with you writing a whole script instead of just the needed functions? Your code definitely doesn't pass the requirements for the task. For example, your add_list
doesn't add together all of the numbers of a list and return the total.
Rafael Pastrana
Courses Plus Student 268 PointsYeah, I haven't had time to check it out on more detail but assumed the problem had something to do with that. Any hints on how to tackle that issue? What about adding the "return" code line?
Kenneth Love
Treehouse Guest TeacherYou don't need input()
to pass any of my code challenges ;)
Kenneth Love
Treehouse Guest TeacherHmm, I don't get any errors with that code and don't see any mistakes in it (other than having a space between print
and the parentheses).
Rafael Pastrana
Courses Plus Student 268 PointsHi Kenneth, thanks for your response. So do you think the error has something to do with the challenge interface? I really want to get over to the next one! :)
Rafael Pastrana
Courses Plus Student 268 PointsHi Kenneth,
I removed what was in the result function and put it in de add_list so that the latter actually adds together all of the numbers in the list. However, I pasted the script again and get again the EOF error.
Maybe it does have to do with writing a whole script. Any thoughts?
number_list = []
def show_intro():
print ("Please enter a list of numbers you want to sum.")
print ("Enter 's' to calculate result.")
def append_list(num):
number_list.append(num)
print ("Added! List has {} items.".format(len(number_list)))
def add_list():
sum = 0
for num in number_list:
sum += int(num)
print ("Sum is {}.".format(sum))
show_intro()
while True:
new_num = input("> ")
if new_num == 's':
add_list()
break
else:
append_list(new_num)
Kenneth Love
Treehouse Guest TeacherTaking out the while True:
gives more informative errors.
You're not required to write an interactive script to solve code challenges, just the required functions/etc. Take a smaller approach and see what that gets you.
Joseph Kato
35,340 PointsIsn't the EOFError
related to the fact that the above script is making a call to input()
but not receiving anything in return?
Kenneth Love
Treehouse Guest TeacherJoseph Kato that's my assumption.
Rafael Pastrana
Courses Plus Student 268 PointsRafael Pastrana
Courses Plus Student 268 PointsCode is: