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 trialHope Watson
5,496 PointsNot sure why this isn't being accepted
I'm not sure why this code isn't being accepted. If I run this code outside of workspaces it comes out correct. I used other examples that others have come up with but I don't understand why this specifically isn't being accepted.
# The dictionary will look something like:
dict1 = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'], 'Kenneth Love': ['Python Basics', 'Python Collections']}
# Each key will be a Teacher and the value will be a list of courses.
#
# Your code goes below here.
def num_teachers(dict1):
return len(dict1)
def num_courses(dict1):
count = 0
for item in dict1.values():
for value in item:
count += 1
return count
def courses(dict1):
list1 = []
for item in dict1.values():
for value in item:
list1.append(value)
return list1
def most_courses(dict1):
count = 0
teacher = ""
for key, value in dict1.items():
if len(value) > count:
count = len(value)
teacher = key
return teacher
def stats(dict1):
list1 = []
count = 0
for key, value in dict1.items():
count = len(value)
list1.append([key, count])
return list1
1 Answer
Aayush Mitra
24,904 PointsThis happens a lot to me too. All you need to do is copy the code that you have written, then refresh the page. If that does not work then I would restart the computer and check the internet connection. Hope that helps. :)
Afloarei Andrei
5,163 PointsAfloarei Andrei
5,163 Pointsthere is nothing wrong in your code. Try it again