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 trialnick schubert
3,535 PointsIt works in Workspaces but not in the challenge, what am I doing wrong?
As the title implies, I have tested this code in both Workspaces and Microsoft Visual Studio Code and it works fine in both instances. However, when I paste the code into the challenge ( or write it all from scratch ) It gives me an error saying: "Bummer: Couldn't find 'most_courses')
What exactly am I doing wrong?
# The dictionary will look something like:
# {'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(teachers):
return len(teachers)
def num_courses(courses):
total_courses = 0
for teacher in courses.values():
for course in teacher:
total_courses += 1
return total_courses
def courses(arguments):
allcourses = []
for courses in arguments.values():
allcourses.extend(courses)
return allcourses
def most_courses(courses):
totalcourses = 0
instructor = ""
for teacher in teachers:
courses = len(teachers[teacher])
if courses > totalcourses:
max_courses = len(teachers[teacher])
instructor = teacher
return instructor
1 Answer
Tyler B
5,787 PointsLooks like the challenge is expecting most_courses
to take teachers
not courses
this seems to work
def most_courses(teachers):
nick schubert
3,535 Pointsnick schubert
3,535 PointsIt works now, thank you very much!