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.

Ivars Jaundzeikars
8,224 PointsChallange task 4 of 4 appears bugged, "'Nonetype' has no len()" error
First 3 tasks are running perfectly. However, when I start 4th task it doesn't let code from the first 3 through saying “object of type 'NoneType' has no len()” in the error message. Even if I put 4th function as blank. Oh, and even when I remove all the len() calls with manual for loops for counting.
I tried reloading browser, clearing cookies, re-doing the task, nothing is working :(
# The dictionary will be something like:
# {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
# 'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Often, it's a good idea to hold onto a max_count variable.
# Update it when you find a teacher with more classes than
# the current count. Better hold onto the teacher name somewhere
# too!
#
# Your code goes below here.
def most_classes(myDict):
winrarTeacher = ""
winrarClasses = 0
for teacher in myDict.keys():
numClasses = len(myDict[teacher])
if numClasses > winrarClasses:
winrarTeacher = teacher
winrarClasses = numClasses
else:
continue
return winrarTeacher
def num_teachers(myDict):
return len(myDict)
def stats(myDict):
myList = []
try:
for item in myDict:
#myList.append([item, myDict[item]])
count = 0
for subItem in myDict[item]:
count += 1
myList.append([item,count])
except:
fYou = True
return myList
def courses(myDict):
allCourses = []
for item in myDict:
allCourses.append(myDict[item])
1 Answer

Kenneth Love
Treehouse Guest TeacherYour courses
function doesn't return anything. So when the validator calls it, the validator just gets back None
, which doesn't have a length.
Ivars Jaundzeikars
8,224 PointsIvars Jaundzeikars
8,224 PointsIt fixed itself. Error was made because code calls len() on what's returned from 4th function. My code on 4th: def courses(myDict): allCourses = [] for item in myDict: allCourses.extend(myDict[item]) return allCourses
omigod, I got so stressed out and spent 30 minutes in like stress :c / c: