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 trialPranav Kumar
3,488 PointsMy code is working Pycharm IDE ,but failing in worspaces # The dic
Workspace is saying task 3 no longer passing while its being complied correctly on my PC
# 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.
dct = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],'Kenneth Love': ['Python Basics', 'Python Collections','java']}
def num_teachers(dct):
teacher=[]
for name in dct:
teacher.append(name)
return len(teacher)
print(num_teachers(dct))
def num_courses(dct):
coursez=[]
for courses in dct.values():
for course in courses:
coursez.append(course)
print(coursez)
return len(coursez)
print(num_courses(dct))
def most_courses(dct):
max_count = 0
max_teacher = ""
for teacher, courses in dct.items():
if len(courses) > max_count:
max_count = len(courses)
max_teacher = teacher
return max_teacher
print(most_courses(dct))
1 Answer
Jon Mirow
9,864 PointsYour approach looks right... are you running it with the print statements in the code?
Pranav Kumar
3,488 PointsPranav Kumar
3,488 PointsYes..